akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <vector>
using namespace std;
#define ll  long long



//long long n,i,k,j;
/*void solve(){
ll n;
cin >> n;
cout << (n-1)/2 << endl;
}*/

int  main() {

  

  /*cin >>t;
  while(t--){
  solve();

  
}*/
 string s , t;
 cin >> s >> t;
 int a =0;
 for(int i =0;i<s.size();i++){
  if(s[i]!=t[i])a++;
 }
 cout << a << endl;
}











Measured memory_bytes: 3892
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#define ll long long
using namespace std;
int n,k;
int a[1001];
ll ps[1001];
ll aa[1000090];
ll ta[1000090];

ll p2[45];
int top=0;
int t2=0;

int main()
{
    cin>>n>>k;
    for (int i=0; i<n; ++i)
    {
        cin>>a[i];
        if (i>0) ps[i]=ps[i-1]+a[i]; else ps[i]=a[i];
    }
    for (int i=0; i<n; ++i)
        for (int j=0; j<n; ++j)
        {
            if (j>i-1)
            {
                aa[top]= ps[j]-ps[i-1];
                top++;
            }
        }
    p2[0]=1;
    for (int i=1; i<45; ++i)
    {
        p2[i]=p2[i-1]*2;
    }
    for (int i=45; i>=0; --i)
    {
        t2=0;
        for (int j=0; j<top; ++j)
        {
            if (aa[j]&p2[i])
            {
                ta[t2++]=aa[j];
            }
        }
        if (t2>=k)
        {
            top=t2;
            for (int j=0; j<top; ++j)
                aa[j]=ta[j];
        }
    }
    for (int i=1; i<k; ++i)
    {
        aa[0]&=aa[i];
    }
    cout<<aa[0]<<endl;
        

    return 0;
}



Measured memory_bytes: 7296
#include <stdio.h>

int main(void){
  int N, M;
  int X, Y, Z;
  int x[100], y[100];
  int i, j, k;
  int war = 0;

  scanf("%d %d %d %d", &N, &M, &X, &Y);
  for(i = 0; i < N; i++){
    scanf("%d", &x[i]);
  }
  for(i = 0; i < M; i++){
    scanf("%d", &y[i]);
  }

  for(Z = X+1; Z <= Y; Z++){
    war = 0;
    for(i = 0; i < N; i++){
      if(x[i] >= Z){
      war = 1;
      break;
      }
    }
    for(i = 0; i < M; i++){
      if(y[i] < Z){
      war = 1;
      break;
      }
    }
    if(war == 0){
      printf("No War\n");
      break;
    }
  }

  if(war == 1){
    printf("War\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
int main(void) {
	int n, i, j=0, cp;
	scanf("%d", &n);
	int a[n], b[n];
	for(i = 0;i < n;i++){
		scanf("%d",&a[i]);
	}
	if(n%2==0){
		for(i = n - 1;i > 0;i -= 2){
			b[j]=a[i];
			j++;
		}
		for(i = 0;i < n;i += 2){
			b[j]=a[i];
			j++;
		}
	}else{
		for(i = n - 1;i >= 0;i -= 2){
			b[j]=a[i];
			j++;
		}
		for(i = 1;i < n;i += 2){
			b[j]=a[i];
			j++;
		}

	}

	/*for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		for (j = 0; j <= i / 2; j++) {
			cp = a[j];
			a[j] = a[i - j];
			a[i - j] = cp;
		}
		for(j = 0;j < n;j++){
					a[j]=b[j];
		}
	}*/

	for (i = 0; i < n - 1; i++) {
		printf("%d ", b[i]);
	}
	printf("%d\n", b[n - 1]);

	return 0;

}

Measured memory_bytes: 3712
#include <stdio.h>

int main(){
  int a, b, c;
  while(scanf("%d%d%d", &a, &b, &c) && (a != -1 || b != -1 || c != -1)){
    if(a < 0 || b < 0) puts("F");
    else if(a + b >= 80) puts("A");
    else if(a + b >= 65) puts("B");
    else if(a + b >= 50 || c >= 50) puts("C");
    else if(a + b >= 30) puts("D");
    else puts("F");
  }
  return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int INF = 1e9+7;
const int mod= 1e9 + 7;


int H, N;
int ans;
pair<double,pair<int,int>> A[10001];
int dp[20001];

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


	FOR(i, 0, 20001)dp[i] = INF;

	cin >> H >> N;

	dp[0] = 0;

	FOR(i, 0, N) {
		cin >> A[i].second.first>>A[i].second.second;
		A[i].first = double(A[i].second.second) / double(A[i].second.first);
	}
	//sort(A, A+ N);
	
	for (int i = 0; i < N;i++) {
		pair<int, int> cur = A[i].second;
		

		dp[cur.first] = min(dp[cur.first],cur.second);
		for (int k=1;k<=H;k++){
			if (dp[k] != INF)dp[k + cur.first] = min(dp[k + cur.first], dp[k] + cur.second);
		}

	}
	int ans = INF;
	for (int i = H; i <= 20000; i++) {
		ans = min(dp[i], ans);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
using namespace std;

int main(){
    int r, D, x2000;
    cin >> r >> D >> x2000;

    int update = x2000;

    for(int i = 1; i <= 10; i++){
        update = r*update - D;
        cout << update << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
ans1 = a[1]
for i in range(1,n):
  big,sml = a[i],ans1
  while sml != 0:
    big,sml = sml,big%sml
  ans1 = big
ans2 = a[-2]
for i in range(n-1):
  big,sml = a[i],ans2
  while sml != 0:
    big,sml = sml,big%sml
  ans2 = big
l1 = [-1]
now = a[0]
for i in range(1,n):
  big,sml = now,a[i]
  while sml != 0:
    big,sml = sml,big%sml
  l1.append(now // big)
  now = big
l2 = [-1]
now = a[-1]
for i in range(n-2,-1,-1):
  big,sml = now,a[i]
  while sml != 0:
    big,sml = sml,big%sml
  l2.append(now // big)
  now = big
l2.reverse()
l3 = [-1]
for i in range(1,n-1):
  big,sml = l1[i],l2[i]
  while sml != 0:
    big,sml = sml,big%sml
  l3.append(big)
l3.append(-1)
now = a[0]
for i in range(n):
  big,sml = now,a[i]
  while sml != 0:
    big,sml = sml,big%sml
  now = big
ans3 = now * max(l3)
#print(now)
#print(l1)
#print(l2)
#print(l3)
#print(ans1,ans2,ans3)
print(max(ans1,ans2,ans3))

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int n,a,b;

signed main() {
    cin >> n >> a >> b;
    cout << min(n*a,b) << endl;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int n;
char s[110],t[110];
int main()
{
	scanf("%d",&n);
	scanf("%s%s",s,t);
	for (int i=0;i<n;++i)
		printf("%c%c",s[i],t[i]);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
using namespace std;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T lcm(T x,T y){
    return x*y/GCD(x,y);
}
long long Pow(long long base,long long x){
    if (x == 0) return 1;
    if (x%2 == 1) return (base*Pow(base,x-1))%MOD;
    long long y = Pow(base, x/2);
    return y*y%MOD;
}

int main(){
    long long n; cin >> n;
    set<long long> St;
    for(int i = 0; i < n; i++){
        long long N,x;
        cin >> N >> x;
        if (N == 0){
            St.insert(x);
            cout << St.size() << endl;
        } else if (N == 1){
            cout << St.count(x) << endl;
        } else {
            St.erase(x);
        }
    }
}
  




Measured memory_bytes: 12448
s = input()
i = 0

while i < len(s):
    if s[i:min(len(s),i+11)] == 'dreameraser':
        i += 11
    elif s[i:min(len(s),i+10)] == 'dreamerase':
        i += 10
    elif s[i:min(len(s),i+7)] == 'dreamer':
        i += 7
    elif s[i:min(len(s),i+6)] == 'eraser':
        i += 6
    elif s[i:min(len(s),i+5)] == 'erase':
        i += 5
    elif s[i:min(len(s),i+5)] == 'dream':
        i += 5
    else:
        print('NO')
        break
        
    if i == len(s):
        print('YES')
        break


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int h,w = 0;
  cin >> h >> w;
  
  vector<string> str(h);
  for(int i=0;i<h;i++){
    cin >> str.at(i);
  }
  
  for(int i=0;i<w+2;i++){
    cout << "#";
  }
  cout << endl;
  for(int i=0;i<h;i++){
    cout << "#" + str.at(i) + "#" << endl;
  }

  for(int i=0;i<w+2;i++){
    cout << "#";
  }
  cout << endl;
  
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

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

    string s;
    cin >> s;
    int n = s.length();
    ll res = 0, cnt = 0;
    for (int i = n - 1; i >= 0; i--)
    {
        if (s[i] == 'W')
            cnt++;
        else
            res += cnt;
    }
    cout << res << endl;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;
typedef pair<int, int> P;

// 自分が最小値かどうか
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  int mn = 1e9+1;
  int ans = 0;
  FOR(i,0,N) {
    int p;
    cin >> p;
    mn = min(mn, p);
    if (mn == p) {
      ans++;
    }
  }
  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);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();
        int ans = solve(A, B, C, D);

        System.out.println(ans);
    }

    private static int solve(int A, int B, int C, int D) {
        int sum = 0;

        sum += Math.min(A, B) + Math.min(C, D);

        return  sum;
    }
}


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

int main()
{
  int n, ans = 0;
  int l, r;
  cin >> n;

  vector<int> h(n), tmp(n, 0);
  for (int i = 0; i < n; i++)
  {
    cin >> h[i];
  }

  while (h != tmp)
  {
    l = -1;
    r = -1;
    for (int i = 0; i < n; i++)
    {
      if (tmp[i] < h[i])
      {
        if (l < 0)
          l = i;

        if ((i != n - 1) and (tmp[i + 1] >= h[i + 1]))
        {
          if (r < 0)
            r = i;
        }
        if ((r < 0) and (i == n - 1))
          r = i;
      }
    }
    for (int i = l; i <= r; i++)
      tmp[i]++;

    ans++;
  }
  cout << ans << "\n";
}


Measured memory_bytes: 256
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

# Written by NoKnowledgeGG @YlePhan

#import math
#mod = 10**9+7



def main():
  """s = input()
  s_l = len(s)
  L = list(set(list(s)))
  #print(L) ('a','b')
  L_l = len(L)
  comp = s[:s_l - 1]# first not comparable
  for i in range(s_l-1):
    i = 1
    for j in range(L_l): 
      if comp.count(L[j]) % 2 == 0:
        if i == len(L):
          print(len(comp))
          exit()
        else:
          i += 1
      else:
        comp = comp[:len(comp)-1]
  print(1)"""
  s=input()
  while True:
    s=s[:-1]
    k=len(s)
    if s[0:k//2]==s[k//2:]:
        print(k)
        exit()
if __name__ == '__main__':
  main()

Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

ll X, Y;
ll MOD = 1e9 + 7;

vector<ll> fac;   //n!(mod MOD)
vector<ll> ifac;  //k!^{MOD-2} (mod MOD)

ll mpow(ll x, ll n) {  //x^n(mod MOD)
    ll ans = 1;
    while (n != 0) {
        if (n & 1) ans = ans * x % MOD;
        x = x * x % MOD;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b) {  //aCbをmod計算
    if (a == 0 && b == 0) return 1;
    if (a < b || a < 0 || b < 0) return 0;
    ll tmp = ifac[a - b] * ifac[b] % MOD;
    return tmp * fac[a] % MOD;
}

int main() {
    cin >> X >> Y;
    // X = a+2b, Y = 2a+b
    // (2X-Y) = 3b
    // (2Y-X) = 3a
    // ans = (a+b)C(a)

    ll a = (2 * Y - X) / 3;
    ll b = (2 * X - Y) / 3;

    if (a + 2 * b != X || 2 * a + b != Y || a < 0 || b < 0) {
        cout << 0 << endl;
        return 0;
    }

    fac = vector<ll>(a + b + 10);
    ifac = vector<ll>(a + b + 10);

    fac[0] = 1;
    ifac[0] = 1;
    for (ll i = 0; i < a + b + 9; i++) {
        fac[i + 1] = fac[i] * (i + 1) % MOD;                 // n!(mod MOD)
        ifac[i + 1] = ifac[i] * mpow(i + 1, MOD - 2) % MOD;  // k!^{MOD-2} (mod MOD)
    }

    ll ans = 1;
    ans = comb(a + b, a) % MOD;

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


Measured memory_bytes: 10624
def cash_co(change):
    ans = 0
    a = (500, 100, 50, 10, 5, 1)
    for i in a:
        co = change // i
        ans += co
        change = change - i * co
    return ans
        

while True:
    n = int(input())
    if n == 0:
        break
        
    change = 1000 - n
    result = cash_co(change)
    print(result)



Measured memory_bytes: 5588
n = int(input())
xy = []
for _ in range(n):
    a = int(input())
    xy.append([list(map(int, input().split())) for _ in range(a)])

ans = 0
for i in range(2**n):
    pat = []
    for j in range(n):
        pat.append((i>>j)%2)
    check = True
    for j in range(n):
        if pat[j]:
            for z in xy[j]:
                if pat[z[0]-1] != z[1]:
                    check = False
    if check:
        ans = max(ans, sum(pat))
print(ans)


Measured memory_bytes: 43100
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
	int N; cin>>N;
	vector<int> X(N);
	for(int i=0;i<N;i++)cin>>X[i];
	int ans=LONG_LONG_MAX;
	for(int i=0;i<=100;i++){
		int tmp=0;
		for(int j=0;j<N;j++){
			tmp+=(X[j]-i)*(X[j]-i);
		}
		ans=min(ans,tmp);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, W; cin >> N >> W;
    int w, v; cin >> w >> v;
    ll ww = w;
    vector<ll> vv[4]; //ll!!
    
    vv[0].push_back(v);
    rep(i, N - 1) {
        cin >> w >> v;
        vv[w - ww].push_back(v);
    }
    rep(i, 4) sort(vv[i].begin(), vv[i].end(), greater<int>());
    rep(i, 4) vv[i].insert(vv[i].begin(), 0);
    //rep(i, 4) {rep(j, vv[i].size()) cout << vv[i][j] << " "; cout << endl;}
    rep(i, 4) rrep(j, 1, vv[i].size()) vv[i][j] += vv[i][j - 1];
    ll ans = 0;
    rep(i, vv[0].size()) {
        rep(j, vv[1].size()) {
            rep(k, vv[2].size()) {
                rep(l, vv[3].size()) {
                    ll val = vv[0][i] + vv[1][j] + vv[2][k] + vv[3][l];
                    ll wei = ww * i + (ww + 1) * j + (ww + 2) * k + (ww + 3) * l;
                    if (wei <= W) ans = max(ans, val);
                }
            }
        }
    }
    cout << ans << endl;
}




Measured memory_bytes: 256
#!/usr/bin/python

# AtCoder Beginner Contest 084
# B: Postal Code

import sys

A, B = [int(w) for w in sys.stdin.readline().split()]
S = sys.stdin.readline().strip()

answer = True
answer = answer and (len(S) == A + B + 1)
answer = answer and (S[A] == '-')
answer = answer and all(c != '-' for c in S[:A] + S[A + 1:])

print("Yes" if answer else "No")


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

#define f first
#define s second
#define pb push_back
#define all(c) c.begin(),c.end()

#define gi(x) scanf("%d", &x)
#define pi(x) printf("%d", x)
#define gl(x) scanf("%lld", &x)
#define pl(x) printf("%lld", x)
#define sp printf(" ")
#define nl printf("\n")

typedef long long int lld;
typedef long double ldb;

#define MAXN 110

vector <int> adj[MAXN];
bool vis[MAXN];
int stamp, tin[MAXN], fup[MAXN];

int cnt = 0;

void dfs(int v, int par){
    vis[v] = true;
    tin[v] = fup[v] = stamp++;
    for(auto i: adj[v]){
        if(i == par) continue;
        if(vis[i]){
            fup[v] = min(fup[v], tin[i]);
        }
        else{
            dfs(i, v);
            fup[v] = min(fup[v], fup[i]);
            if(fup[i] > tin[v]) cnt++;
        }
    }
}

main(){
    int n, m;
    cin >> n >> m;
    for(int i = 1, x, y; i <= m; ++i){
        cin >> x >> y;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    for(int i = 1; i <= n; ++i){
        if(!vis[i]) dfs(i, -1);
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
import sys
import re
input = lambda:sys.stdin.readline()
import functools
@functools.lru_cache(maxsize = 10000)

def Main():
  a, b = input().split()
  if a == "H" and b == "H":
    print("H")
  elif a == "D" and b == "H":
    print("D")
  elif a == "D" and b == "D":
    print("H")
  else:
    print("D")
    
if __name__ == '__main__':
  Main()

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

#define MAX 100000

signed main(){
    int n,m;
    cin >> n >> m;
    int cnt[MAX + 1] = {};
    int cntmod[m] = {};
    REP(i,n){
        int x;
        cin >> x;
        cnt[x]++;
        cntmod[x % m]++;
    }
    int ans = 0;
    int t = cntmod[0] / 2;
    ans += t;
    cntmod[0] -= 2 * t;
    if(m % 2 == 0){
        int t = cntmod[m / 2] / 2;
        ans += t;
        cntmod[m / 2] -= 2 * t;
        for(int i = 1; i < m / 2; i++){
            int t = min(cntmod[i], cntmod[m - i]);
            ans += t;
            cntmod[i] -= t;
            cntmod[m - i] -= t;
        }
    }else{
        for(int i = 1; i <= m / 2; i++){
            int t = min(cntmod[i], cntmod[m - i]);
            ans += t;
            cntmod[i] -= t;
            cntmod[m - i] -= t;
        }
    }
    for(int i = 1; i <= MAX; i++){
        int t = min(cnt[i] / 2, cntmod[i % m] / 2);
        ans += t;
        cntmod[i % m] -= t * 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

using namespace std;

#define lli long long int
#define REP(i,n) for(int i=0;i<n;i++)
#define REP2(i,n) for(int i=1;i<=n;i++)
#define DEBUG 0

int main(){

	string s;
	cin>>s;

	for(lli i=0;i<s.size()-1;i++){
		if(s.at(i)==s.at(i+1)){
			cout<<i+1<<" "<<i+2<<endl;
			return 0;
		}
	}
	for(lli i=0;i<s.size()-2;i++){
		if(s.at(i)==s.at(i+2)){
			cout<<i+1<<" "<<i+3<<endl;
			return 0;
		}
	}

	cout<<-1<<" "<<-1<<endl;

	return 0;
}

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

int main() {
  int n, m; cin >> n >> m;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int s = 0;
  rep(i,n) s += a[i];
  int cnt = 0;
  rep(i,n) {
    if (a[i]*(4*m) >= s) cnt++;
  }
  if (cnt >= m) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int,input().split()))
A.append(0)
B = list(map(int,input().split()))
C = list(map(int,input().split()))
Sat = 0
for i in range(n):
    Sat += B[A[i]-1]
    if A[i]+1 == A[i+1]:
        Sat += C[A[i]-1]
print(Sat)

Measured memory_bytes: 3064
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int K = Integer.parseInt(sc.next());
        String s = sc.next();
        sc.close();
        char[] arr = s.toCharArray();
        arr[K - 1] = s.toLowerCase().toCharArray()[K - 1];
        System.out.println(String.valueOf(arr));
    }
}

Measured memory_bytes: 23252
import math
def main():
    N = int(input())
    mi = 10**13
    for i in range(1, math.floor(math.sqrt(N))+1):
        if N % i == 0:
            m = i - 1 + (N//i) - 1
            if mi > m:
                mi = m
    print(mi)
if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
N = int(input())

T, A = map(int, input().split())

H = list(map(int, input().split()))

mi = abs(T-H[0]*0.006-A)
num = 1

for i in range(N):
    tmp = abs(T-H[i]*0.006-A)
    if tmp<mi:
        mi = tmp
        num = i+1
        
print(num)

Measured memory_bytes: 3064
# a-k = k-b (if a>b) k -a = b-k (if a < b)
# a+b = 2k 
# if a+b % 2 == 1 IMPOSSIBLE else a+b/2
a,b = map(int,input().split())
if (a+b) % 2:
    print("IMPOSSIBLE")
else:
    print((a+b)//2)


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

int main(){
    int n; cin>>n;
    vector<char> s(n);
    rep(i,n) cin>>s[i];
    int sum=1;
    for(int i=1;i<n;i++){
        if(s[i-1]!=s[i]) sum++;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <climits>
#define ll long long 
#define MAX 25 * 1e13


using namespace std;

int MOD = 1000000007;
int calc1(int num){
  int cnt1 = 0;
  while( num > 0 ){
    if( num % 2 ) cnt1++;
    num = num >> 1;
  }
  return cnt1;
}
int main(){
  int n;
  cin >> n;
  vector<vector<int>> a(n+1 , vector<int>(n+1));
  vector<int> dp(1<<n);
  for(int i = 0 ; i < n ; i++ ){
    for( int j = 0 ; j < n ; j++ ){
      cin >> a[i][j];
    }
  }
  dp[0] = 1;
  for( int i = 1 ; i < (1 << n) ; i++ ){
    //current state is i , to be calculated
    int cntm = calc1(i) - 1;//# of 1 , minus 1 to get id
    for( int pos = 0 ; pos < n ; pos ++){//pos of women
      if( i & ( 1 << pos ) ){//test pos
        int pre = i ^ (1<< pos);
        if( a[cntm][pos] ){
          dp[i] = ( dp[i] + dp[pre] ) % MOD; 
        } 
      }
    }
  }
  cout << dp[(1<<n)-1] << endl;
  return 0;
}


Measured memory_bytes: 8448
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scanf("%d %d", &n, &k)
	ports := scanIntSlice(n)

	visited := map[int]int{}
	town := 1
	jump := 0
	loop := 0
	for true {
		if j, ok := visited[town]; ok {
			loop = j
			break
		}
		visited[town] = jump
		jump++
		town = ports[town-1]
	}

	if k <= loop {
		steps := k
		target := 1
		for steps > 0 {
			target = ports[target-1]
			steps--
		}
		fmt.Printf("%d\n", target)
	} else {
		k = k - loop
		steps := k % (jump - loop)
		target := town
		for steps > 0 {
			target = ports[target-1]
			steps--
		}
		fmt.Printf("%d\n", target)
	}

}

func scanIntSlice(size int) []int {
	input := []int{}
	for i := 0; i < size; i++ {
		var in int
		fmt.Scanf("%d", &in)
		input = append(input, in)
	}
	return input
}


Measured memory_bytes: 17704
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> pi;

lint n, a[100005], b[100005], sum;
vector<int> gph[100005];

lint dfs(int x, int p){
	lint sum = 0;
	vector<lint> v;
	for(auto &i : gph[x]){
		if(i != p){
			lint t = dfs(i, x);
			v.push_back(t);
			sum += t;
		}
	}
	if(v.size() == 0) return a[x];
	lint death = sum - a[x];
	lint alive = a[x] - death;
	if(death < 0 || alive < 0){
		puts("NO");
		exit(0);
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	if(v.size() > 1 && v[0] - alive > death){
		puts("NO");
		exit(0);
	}
	if(v.size() == 1 && v[0] != alive){
		puts("NO");
		exit(0);
	}
	return alive;
}

int main(){
	scanf("%lld",&n);
	for(int i=1; i<=n; i++){
		scanf("%lld",&a[i]);
	}
	for(int i=0; i<n-1; i++){
		int s, e;
		scanf("%d %d",&s,&e);
		gph[s].push_back(e);
		gph[e].push_back(s);
	}
	if(n == 2){
		puts(a[1] == a[2] ? "YES" : "NO");
		return 0;
	}
	for(int i=1; i<=n; i++){
		if(gph[i].size() > 1){
			if(dfs(i, -1) != 0){
				puts("NO");
				return 0;
			}
			puts("YES");
			return 0;
		}
	}
}


Measured memory_bytes: 15872
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		String words[] = new String[num];
		for(int i = 0; i < num; i ++) {
			words[i] = sc.next();
		}
		boolean isCorrect = true;

		end: for(int i = 1; i < num; i ++) {
			for(int j = 0; j < i; j ++) {
				if(words[i].equals(words[j])) {
					isCorrect = false;
					break end;
				}
			}
		}
		if(isCorrect) {
			end: for(int i = 1; i < num; i ++) {
				char firstChar = words[i].charAt(0);
				char lastChar = words[i - 1].charAt(words[i - 1].length() - 1);
				if(firstChar != lastChar) {
					isCorrect = false;
					break end;
				}
			}
		}
		System.out.println(isCorrect ? "Yes" : "No");
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main () {
	int n,q;
	string b;
	int cnt=0;
	cin>>n>>q>>b;
	int num[n];
	int l[q],r[q];
	for(int i=0; i<q; i++){
		cin>>l[i]>>r[i];
	}
	num[0]=0; 
	for(int i=1; i<n; i++){
		if(b[i]=='C' and b[i-1]=='A'){
			cnt++; 
		}
		num[i]=cnt;
	}
	for(int i=0; i<q; i++){
		cout<<num[r[i]-1]-num[l[i]-1]<<endl;
	}
}

Measured memory_bytes: 2176
<?php
fscanf(STDIN,"%d",$n);
$a_li = explode(" ",trim(fgets(STDIN)));

$sum = 0;
array_unshift($a_li,0);
for($j=0;$j<$n;$j++){
    $sum += abs($a_li[$j+1]-$a_li[$j]);
}
$sum += abs($a_li[$n]);

for($i=1;$i<=$n;$i++){
  if($i==$n){
    $remove = abs($a_li[$i]-$a_li[$i-1])+abs($a_li[$i]);
    $add = abs($a_li[$i-1]);
  }else{
   $remove = abs($a_li[$i]-$a_li[$i-1])+abs($a_li[$i+1]-$a_li[$i]);
   $add = abs($a_li[$i+1]-$a_li[$i-1]);
  }
  echo ($sum-$remove+$add)."\n";
}


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

#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define pb push_back

using namespace std;
int a[200000], b[200000], n, ans;;
vector < int > g[200000];
int dfs(int v)
{
    vector < int > k;
    k.clear();
    for (auto u: g[v]){
        k.pb(dfs(u));
    }
    sort(k.begin(), k.end());
    reverse(k.begin(), k.end());
    int t = 0;
    for (int i = 0; i < k.size(); i++) t = max(i + 1 + k[i], t);
    return t;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    for (int i = 2; i <= n; i++){
        cin >> a[i];
        g[a[i]].pb(i);
    }
    ans = dfs(1);
    cout << ans;
}


Measured memory_bytes: 16256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for( int i=a; i<b; i++ )
#define REP(i,n) rep(i,0,n)
#define INF 1000000000000
using lli = long long int;
using ulli = unsigned long long int;
typedef pair<lli,lli> P;

struct edge{ int u, v; lli cost; };
struct DirectedGraph
{
  int vertex_num;
  int edge_num;
  vector<edge> edge_list;
  vector< vector<int> > adj_list;
	vector< vector<lli> > distance_matrix;
};

template <typename T>
vector<int> argsort(const vector<T> &v) {

  // initialize original index locations
  vector<int> idx(v.size());
  iota(idx.begin(), idx.end(), 0);

  // sort indexes based on comparing values in v
  sort(idx.begin(), idx.end(),
       [&v](int i1, int i2) {return v[i1] < v[i2];});

  return idx;
}

template<typename T>
void displayVector(vector<T> v)
{
	lli n = v.size();
	REP(i,n){
		cout << v[i] << " " ;
	}
	cout << endl;
}


int main(){
	int N, M; cin >> N >> M;
	vector<lli> a(N); REP(i, N){ cin >> a[i]; }
	vector<P> x(M); REP(i, M){ cin >> x[i].first >> x[i].second; }

	sort(x.begin(), x.end(),
       [&x](P p1, P p2) {return p1.second > p2.second;});

	vector<lli> d;
	int iter = 0;
	while( d.size() <= N && iter<M){
		REP(i, x[iter].first ){ d.push_back( x[iter].second ); }
		iter++;
	}
	d.resize(N);

	sort(a.begin(), a.end());
	REP(i, N){
		if(a[i] < d[i]){ a[i] = d[i]; 
		} else{ break; }
	}

	cout << accumulate(a.begin(), a.end(), 0LL) << endl;
	return 0;
}

Measured memory_bytes: 7624
#include<bits/stdc++.h>
using namespace std;
vector<int> l[200005];
int visited[200005];
map<int,int> mp;
int main()
{
   int n,k;
   cin>>n>>k;
   int a[n];

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

   int dp[n+1];
   //memset(dp,0,sizeof(dp));
   for(int i=0;i<n;i++)
      dp[i]=INT_MAX;
   dp[0]=0;
   dp[1]=abs(a[1]-a[0]);
   for(int i=2;i<n;i++)
   {
      for(int j=1;j<=k;j++)
       { if(i>=j)
         {
              dp[i]=min(dp[i],abs(a[i]-a[i-j])+dp[i-j]);
         }
       }
   }
   // for(int i=0;i<n;i++)
   // cout<<dp[i]<<" ";

      cout<<dp[n-1];
}


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

int K, N, h[100000];

int main(){
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        cin >> h[i];
    }
    sort(h, h + N);
    int ans = 2e9;
    for(int i = 0; i + K <= N; i++){
        ans = min(ans, h[i + K - 1] - h[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
using namespace std;
typedef long long ll;

int main (){
    int n;
    cin >> n;
    int N = 3*n;
    vector<int>a(N);

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

    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());

    ll ans=0;

    for(int i=0; i<n; i++){
        ans += a[2*i+1];
    } 

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1408
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n; cin >> n;
  vector<string> s(n);
  rep(i,n) cin >> s[i];
  vector<int> a(n);
  vector<int> b(n);
  rep(i,n){
    int mx=0;
    rep(j,s[i].size()){
      if(s[i][j]==')') mx++;
      else mx--;
      chmax(a[i],mx);
    }
    mx=0;
    for(int j=s[i].size()-1;j>=0;j--){
      if(s[i][j]=='(') mx++;
      else mx--;
      chmax(b[i],mx);
    }
  }
  vector<pair<int,string> > v1(0);
  vector<pair<int,string> > v2(0);
  rep(i,n){
    if(b[i]-a[i]>=0) v1.push_back(pair<int,string>(a[i],s[i]));
    else v2.push_back(pair<int,string>(b[i],s[i]));
  }
  sort(all(v1));
  sort(all(v2));
  reverse(all(v2));
  string t;
  for(auto c:v1){
    t+=c.second;
  }
  for(auto c:v2){
    t+=c.second;
  }
  int check=0;
  rep(i,t.size()){
    if(t[i]=='(') check++;
    else check--;
    if(check<0){
      cout << "No" << endl;
      return 0;
    }
  }
  if(check!=0){
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 84364
#include <bits/stdc++.h>
#define N 1000000007;

using namespace std;

int main()
{
 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 string s,t;
 cin>>s>>t;
 int nb=0;
 for(int i=0;i<t.length();i++)
 {
     if (s[i]!=t[i])
        nb++;
 }
 cout<<nb;
 return(0);
}


Measured memory_bytes: 3776
#pragma comment(linker, "/stack:200000000")
       #pragma GCC optimize ("Ofast")
        #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
         
         
        #include <iostream>
        #include <iomanip>
        #include <sstream>
        #include <cstring>
        #include <vector>
        #include <deque>
        #include <queue>
        #include <set>
        #include <map>
        #include <valarray>
        #include <iterator>
        #include <functional>
        #include <limits>
        #include <algorithm>
        #include <numeric>
        #include <cmath>
        #include <cassert>
        #include <unordered_map>
        #include <stack>
        using namespace std;
        #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
         #define trace(x) cerr << #x << ": " << x << " " << endl;
     
        typedef int64_t ll;
     
        #define endl '\n'
        #define int ll
        ll mod=1e9+7;
        ll mod1=1e9+5;
        ll power(ll a,ll b)
        {
            if(b==0) return 1;
            else if(b%2==0)
                return power((((a%mod)*(a%mod))%mod),b/2)%mod;
            else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
        }
        
          
        
        
        int32_t main()
        {
            IOS
           
           
            
            int n;
            cin>>n;
            if(n%2==0)
            {
                cout<<"0.500000";
            }
            else
            {
                cout<<fixed<<setprecision(10)<<(double)((n+1)/2)/(double)n;
            }
        }

Measured memory_bytes: 256
x, y = map(int, input().split())
g1 = [1, 3, 5, 7, 8, 10, 12]
g2 = [4, 6, 9, 11]
if x == y:
    print('Yes')
elif x in g1 and y in g1:
    print('Yes')
elif x in g2 and y in g2:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
n=int(input())
a=list(map(int,input().split()))

if n<=2:
    print(1)
    exit(0)


flg=0
cnt=0

tmp=[]
for i in range(1,n):
    if a[i]>a[i-1]:
        tmp.append(1)
    elif a[i]==a[i-1]:
        tmp.append(0)
    else:
        tmp.append(-1)
flg=0
swi=0
for j in range(len(tmp)):
    if swi==1:
        flg=tmp[j]
        swi=0
        continue
    
    if flg==0:
        flg=tmp[j]
    elif flg==1:
        if tmp[j]==-1:
            cnt+=1
            flg=-1
            swi=1
    elif flg==-1:
        if tmp[j]==1:
            cnt+=1
            flg=1
            swi=1

print(cnt+1)

Measured memory_bytes: 19964
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

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

	char prev = s[0];
	int change = 0;
	for (auto c : s) {
		if (c != prev) {
			change++;
		}
		prev = c;
	}
	cout << change << endl;
	return 0;
}


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

bool is(int a){
  bool b=false;
  while(true){
    if(a%10==3){
      return true;
    }
    else a/=10;
    if(a==0) return false;
  }
}

int main() {
  int n;cin>>n;
  for(int i=1;i<=n;i++){
    if(i%3==0||is(i))cout<<" "<<i;
  }
    
  cout << endl;
}


Measured memory_bytes: 3100
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define mp make_pair
#define vvll vector <vll>
#define vsi vector <si>
#define forn(i, n) for (int i = 0; i < (n); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define MANX MAXN


const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;
ll lcm(ll a,ll b)
{
    return a*b/__gcd(a,b);
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
    freopen("a.in","r",stdin);
    #endif
    ll x;
    cin>>x;
    ll t=__gcd(360ll,x);
    cout<<360/t;


    //n=1 ?
    //recursion - matrix exponential
    //linear algebra - just a joke
    //check ios_base, MAXN, mod1 before submit
    //if debug more than 15 minutes - write stress
    //compression
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<string> vs;
#define fo(i, a, b) for (int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(s) s.begin(), s.end()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
int main()
{
  int n;
  string s, t;
  cin >> n >> s >> t;

  re(i, n) {
    cout << s[i] << t[i];
  }
  cout << endl;

  return 0;
}


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

int main(void)
{
	string men, female;
	int turn, menp=0, femalep=0;

	cin >> turn;

	for (int i = 0; i < turn; i++)
	{
		cin >> men >> female;
		if (men > female) menp += 3;
		else if (female > men) femalep += 3;
		else 
		{
			menp++; femalep++;
		}
	}
	cout << menp << " " << femalep << endl;
	return 0;
}


Measured memory_bytes: 3180
n,k = map(int, input().split())
r,s,p = map(int, input().split())
t = input()

ans = 0
flag = [True]*k

for i in range(1,n+1):
    if i-k <= 0:
        if t[i-1] == 'r':
            ans += p
        elif t[i-1] == 's':
            ans += r
        else:
            ans += s
    else:
        if t[i-1] == t[i-k-1]:
            if flag[(i-1)%k]:
                flag[(i-1)%k] = False
            else:
                flag[(i-1)%k] = True
                if t[i-1] == 'r':
                    ans += p
                elif t[i-1] == 's':
                    ans += r
                else:
                    ans += s
        else:
            flag[(i-1)%k] = True
            if t[i-1] == 'r':
                ans += p
            elif t[i-1] == 's':
                ans += r
            else:
                ans += s

print(ans)

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF INT_MAX/3

ll ryuka[87];

void cal() {
    ryuka[0] = 2, ryuka[1] = 1;
    repl(i, 2, 87) ryuka[i] = ryuka[i - 1] + ryuka[i - 2];
}

int main(){
    cin.sync_with_stdio(false);
    int n;
    cin >> n;
    cal();
    cout << ryuka[n] << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {

	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	args := strings.Split(sc.Text(), " ")
	n, _ := strconv.Atoi(args[0])
	t, _ := strconv.ParseInt(args[1], 10, 64)

	q, _ := strconv.Atoi(args[2])

	pos := make([]int64, n)
	direction := make([]bool, n)

	for i := 0; i < n; i++ {
		sc.Scan()
		args = strings.Split(sc.Text(), " ")

		pos[i], _ = strconv.ParseInt(args[0], 10, 64)
		q, _ := strconv.Atoi(args[1])
		if q == 1 {
			direction[i] = true
		}
	}

	qq := make([]int, q)
	for i := 0; i < q; i++ {
		sc.Scan()
		args = strings.Split(sc.Text(), " ")

		qq[i], _ = strconv.Atoi(args[0])
	}

	ans(n, q, t, pos, direction, qq)

}

func ans(n, q int, t int64, pos []int64, dir []bool, qq []int) {

	colleation := []int64{} // syoutotu positon

	for i := 1; i < n; i++ {
		if dir[i-1] == dir[i] {
			continue
		}
		colleation = append(colleation, (pos[i-1]+pos[i])/2)

	}
	//fmt.Println(colleation)
	for i := 0; i < q; i++ {
		var ans int64
		ans = int64(-9999999)
		if dir[qq[i]-1] == true {
			// 東向きなら現ポジから＋方向で一番近い衝突点との距離を求めて、Tとの差が
			for _, v := range colleation {
				if v <= pos[qq[i]-1] {
					continue
				} else {
					// 衝突予定点が確定。衝突点との距離がT以下なら衝突点で停止
					if v-pos[qq[i]-1] <= t {
						ans = v
					} else {
						ans = pos[qq[i]-1] + int64(t)
					}
					break
				}
			}
			if ans == -9999999 {
				ans = pos[qq[i]-1] + int64((t))
			}

		} else {
			// nishi向きなら現ポジから-方向で一番近い衝突点との距離を求めて、Tとの差が
			for j := len(colleation); j > 0; j-- {
				if colleation[j-1] >= pos[qq[i]-1] {
					continue
				}
				v := colleation[j-1]
				//fmt.Printf("hoge=%d\n", v)
				// 衝突予定点が確定
				if pos[qq[i]-1]-v <= t {
					ans = v
				} else {
					ans = pos[qq[i]-1] - int64((t))
				}
				break

			}
			if ans == -9999999 {
				ans = pos[qq[i]-1] - int64((t))
			}

		}
		fmt.Printf("%d\n", ans)

	}

}



Measured memory_bytes: 5888
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;


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

    vector<int> vec_x(n);
    vector<int> vec_y(n);

    rep(i,n){
        cin >> vec_x.at(i) >> vec_y.at(i);
    }

    int kaijou = 1;
    rep(i,n){
        kaijou = kaijou * (i+1);
    }

    int count = 0;
    for(int i = 0; i < n - 1; i ++){
        for(int j = i + 1; j < n; j ++){
            count++;
        }
    }

    int tmp = kaijou * (n-1) / count;

    double ans = 0;
    for(int i = 0; i < n - 1; i ++){
        for(int j = i + 1; j < n; j ++){
            double xxx = (vec_x.at(i) - vec_x.at(j)) * (vec_x.at(i) - vec_x.at(j));
            double yyy = (vec_y.at(i) - vec_y.at(j)) * (vec_y.at(i) - vec_y.at(j));
            ans += sqrt(xxx+yyy) * tmp;
        }
    }

    cout<<std::setprecision(20)<<ans/kaijou<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;


int main(){
	const int MAX_NUM=1000000;
	int table[MAX_NUM]={};
	for(int i=2;i<1001;i++){
		if(table[i]==1)continue;
		for(int j=i*2;j<MAX_NUM;j+=i){
			table[j]=1;
		}
	}

	int input;
	while(cin>>input){
		int count=0;
		for(int i=2;i<=input;i++){
			//cout<<"table:"<<i<<"="<<table[i]<<"\n";		
			if(table[i]==0)count++;
		}
		cout<<count<<"\n";
	}
	return 0;
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main()
    {
        var hw = ReadLine().Split().Select(int.Parse).ToArray();
        var h = hw[0];
        var w = hw[1];
        var map = new int[h, w];
        for (int i = 0; i < h; i++)
        {
            var line = ReadLine();
            for (int j = 0; j < w; j++)
            {
                map[i, j] = line[j] == '.' ? 0 : 1;
            }
        }
        var b = true;
        for (int i = 0; i < h; i++)
        {
            for (int j = 0; j < w; j++)
            {
                if (map[i, j] == 1) if (!check(map, i, j, h, w)) b = false;
            }
        }
        WriteLine(b ? "Yes" : "No");
    }
    static int[] dx = { 1, 0, -1, 0 };
    static int[] dy = { 0, -1, 0, 1 };
    static bool check(int[,] map, int i, int j, int h, int w)
    {
        for (int k = 0; k < 4; k++)
        {
            if ((uint)(i + dy[k]) < h && (uint)(j + dx[k]) < w && map[i + dy[k], j + dx[k]] == 1) return true;
        }
        return false;
    }
}


Measured memory_bytes: 13376
import collections

#まずは代入
n = int(input())
s = [input() for _ in range(n)]
c = collections.Counter(s).most_common() #もうリストにしちゃった<3
d = collections.Counter([c[x][1] for x in range(len(c))])
#この時点で, cは個数が多い順に並んでる
#たとえば入力例1だと
#[('vet', 2), ('beet', 2), ('beat', 1), ('bed', 1), ('bet', 1)]

ans = []
max = c[0][1] #最大の個数は何か? 数値を代入
for item,count in c[0:d[max]]:
	if count==max:
		ans.append(item)
	else:
		break #もうこれ以下は弱いのしかないのでbreakします

ans.sort() #辞書順に並べる

for i in range(len(ans)):
	print(ans[i])

Measured memory_bytes: 45040
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = sum(b)
for i in range(n-1):
    if a[i+1] - a[i] ==1:
        ans += c[a[i]-1]
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	int n,a[25],b[25],sum=0;
	vector<int>v;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<n;i++)
	{
		cin>>b[i];
	}
	for(int i=0;i<n;i++)
	{
		v.push_back(a[i]-b[i]);
	}
	for(int i=0;i<n;i++)
	{
		if(v[i]>0)sum+=v[i];
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    int n;
    int L[200];

    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> L[i];
    }
    int max,sum;
    sort(L, L+n, greater<int>());
    max = L[0];

    for(int j = 1; j < n; j++){
        sum += L[j];
    }

    if(max < sum){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    } 

}

Measured memory_bytes: 256
n,m=map(int,input().split())
ans=[0 for i in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    a,b=a-1,b-1
    ans[a]+=1
    ans[b]+=1
for i in range(n):
    print(ans[i])

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

bool comp(const pair<long, long> &a, const pair<long, long> &b) {
	return a.first < b.first;
}

int main() {
	int N;
	long M;
	cin >> N >> M;
	vector<pair<long, long>> AB(N);
	for (int i = 0; i < N; ++i) cin >> AB[i].first >> AB[i].second;
	sort(AB.begin(), AB.end(), comp);
	long ans = 0, sum = 0;
	for (int i = 0; sum < M; ++i) {
		if (M - sum < AB[i].second) {
			ans += (M - sum) * AB[i].first;
			sum = M;
		}
		else {
			ans += AB[i].first * AB[i].second;
			sum += AB[i].second;
		}
	}
	cout << ans;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++)
#define RFOR(i, a, n) for (ll i = (ll)n - 1; i >= (ll)a; i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define bra(first, second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
ll INF = 1001001001001001001;
long double EPS = 1e-9;
long double PI = 3.141592653589793238;
template <typename T>
void remove(std::vector<T> &vector, unsigned int index)
{
   vector.erase(vector.begin() + index);
}

using Graph = vector<vector<tuple<ll, ll, ll>>>;

// MOD確認

ll P[110];

int main(){
   ll X,N;
   cin >> X >> N;
   rep(i,N) cin >> P[i];
   ll ans = INF;
   ll m = INF;
   RFOR(i,-200,200){
      bool flag = 0;
      rep(j,N){
         if(i == P[j]) flag = 1;
      }
      if(flag) continue;
      else{
         if(m >= abs(X-i)){
            ans = i;
            m = abs(X-i);
         }
      }
   }
   cout << ans << endl;
}


Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<climits>
#include<vector>
#include <sstream>
#include<algorithm>

using namespace std;

int main(void) {

	bool alp[26] = {false};
	string in;
	cin >> in;
	if (in.size() == 26) {
		int maxAlp = 0;

		for (int i = 25;i >= 0;--i) {
			if (maxAlp < in[i]) { 
				maxAlp = in[i];
			}else {
				for (int j = 25;j > 0;--j) {
					if (in[i] < in[j])	{
						in[i] = in[j];
						in.resize(i + 1);
						cout << in;
						return 0;
					}
				}
				
			}
		}
		cout << -1;
		return 0;

	}else {

		for (int i = 0;i < in.size();++i) {
			alp[in[i]-'a']=true;
		}
		for (int i = 0;i < 26;++i) {
			if (alp[i] == false) {
				in = in + (char)('a' + i);
				cout << in;
				return 0;
			}
		}

	}
	

}

Measured memory_bytes: 256