akhauriyash/Code-Regression huggingface dataset:
import sys,math,collections,itertools
input = sys.stdin.readline

def solve(n0,n1):
    #wolf = 1,sheep=0
    ws = [-1]*len(s)
    ws[0]=n0
    ws[1]=n1
    for i in range(1,len(s)-1):
        if s[i]=='o' and ws[i]==0:#羊で、両隣が同じと証言
            ws[i+1]=ws[i-1]
        elif  s[i]=='x' and ws[i]==0:#羊で、両隣が違うと証言
            ws[i+1]=(ws[i-1]+1)%2
        elif s[i]=='o' and ws[i]==1:#狼で、両隣が違う証言
            ws[i+1]=(ws[i-1]+1)%2
        elif s[i]=='x' and ws[i]==1:#狼で、両隣が同じと証言
            ws[i+1]=ws[i-1]
    if ws[0] == ws[-2] and ws[1]==ws[-1]:
        return ws[1:-1]
    else:
        return 0

N=int(input())
s=input().rstrip()
s=s[-1]+s+s[0]

for i in range(2):
    for j in range(2):
        ws = solve(i,j)
        if ws:
            for w in ws:
                if w==0:
                    print('S',end='')
                else:
                    print('W',end='')
            exit()
print(-1)
            


Measured memory_bytes: 10784
s,a,b=[set(map(int,input().split()))for j in[0]*3];c=1;N=M=0;k=x=max(a)
while k:A=k in a;B=k in b;N+=A;M+=B;c*=[M*N-x+k,N,M,1][A*2+B];c%=10**9+7;k-=1
print(c)

Measured memory_bytes: 41708
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
using namespace std;
const int N=200005;
struct node
{
	int id,v0,v1;
}g[N],t;
bool operator <(node a,node b)
{
	if(1ll*a.v0*b.v1!=1ll*b.v0*a.v1)
		return 1ll*a.v0*b.v1>1ll*b.v0*a.v1;
	return a.id<b.id;
}
set<node> q;
int n,i,j,head[N],adj[N],nxt[N],a[N],p[N],fa[N];
long long ans;
int find(int x)
{
	return !p[x]?x:p[x]=find(p[x]);
}
int main()
{
	scanf("%d",&n);
	for(i=1;i<n;++i)
	{
		scanf("%d",&j);
		adj[i]=i+1;
		nxt[i]=head[j];
		head[j]=i;
		fa[i+1]=j;
	}
	for(i=1;i<=n;++i)
	{
		scanf("%d",a+i);
		if(a[i]==0)
			g[i]=(node){i,1,0};
		else
			g[i]=(node){i,0,1};
		if(i>1)
			q.insert(g[i]);
	}
	while(!q.empty())
	{
		t=*(q.begin());
		q.erase(t);
		i=find(t.id),j=find(fa[i]);
		ans+=1ll*g[j].v1*g[i].v0;
		if(j>1)
			q.erase(g[j]);
		g[j].v0+=g[i].v0,g[j].v1+=g[i].v1;
		p[i]=j;
		if(j>1)
			q.insert(g[j]);
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 19840
#include <bits/stdc++.h>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int, int>;
 
int main()
{
    string o, e;
    cin >> o;
    cin >> e;
    string ans;
    rep(i, e.size()) {
        ans.push_back(o[i]);
        ans.push_back(e[i]);
    }
    if(o.size() != e.size()) {
        ans.push_back(o[o.size() - 1]);
    }
    cout << ans << endl;
    return 0;
}

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

#define endl '\n'
#define fr first
#define sc second

using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> ii;
const int NMAX = 1e5 + 1, INF = 1e9;
ll LINF = 1e18;
const double EPS = 1e-8;

main()
{
//    freopen("input.txt", "r", stdin);
    int n;
    scanf("%d", &n);
    if (n / 100 == n % 10) {
        printf("Yes");
    } else {
        printf("No");
    }
}


Measured memory_bytes: 256
N=int(input())
H = list(map(int,input().split( )))
i = 1
s = 0
max = 0

while i < N + 1:
    if max - 1 > H[i-1]:
        s = 1
        break
    if max < H[i-1]:
        max = H[i-1]
    i = i+1

if s == 0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef vector<ll> vll;
typedef map<ll, vll> msll;

int main() {FIN
	
	ll n, i, j, k, c = 0;
	cin >> n;
	vll hs(n);
	msll df;
	for (i = 0; i < n; i++) {
		cin >> hs[i];
		df[i - hs[i]].push_back(i);
	}
	for (auto it = df.begin(); it != df.end(); it++)
		sort(it->second.begin(), it->second.end());
	
	for (i = 0; i < n; i++) {
		k = (i + hs[i] + 1);
		if (k < n) {
			auto it = df.find((i + hs[i]));
			if (it != df.end()) {
				j = lower_bound(it->second.begin(), it->second.end(), k) - it->second.begin();
				c += (it->second.size() - j);
			}
		}
	}
	
	cout << c << "\n";
	return 0;
}


Measured memory_bytes: 24980
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
using namespace std;
int main(){
	float a, b;
	cin >> a >> b;
	float c = a / b;
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long V = sc.nextLong();
        long B = sc.nextLong();
        long W = sc.nextLong();
        long T = sc.nextLong();
        long dist = Math.abs(A-B);
        if(((V-W)*T) >= dist){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }

}


Measured memory_bytes: 35808
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;
const ll LINF=1e18;

int main(){
    int n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll sum[n+1];
    sum[0]=0;
    for(int i=0;i<n;i++){
        sum[i+1]=sum[i]+a[i];
    }
    ll dp[n+1][n+1]={};
    for(int i=2;i<=n;i++){
        for(int l=0;l+i<=n;l++){
            int r=l+i;
            ll mn=LINF;
            for(int m=l+1;m<r;m++){
                mn=min(mn,dp[l][m]+dp[m][r]);
            }
            dp[l][r]=mn+sum[r]-sum[l];
        }
    }
    cout<<dp[0][n]<<endl;
}

Measured memory_bytes: 1664
from collections import deque
n, q = map(int, input().split())
tree = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = map(int, input().split())
    tree[a - 1].append(b - 1)
    tree[b - 1].append(a - 1)

query = [0] * n
for _ in range(q):
    q, x = map(int, input().split())
    query[q - 1] += x


def bfs(tree, start, n, query):
    visited = [False] * n
    visited[start] = True
    que = deque([start])
    while que:
        node = que.popleft()
        cost = query[node]
        for n in tree[node]:
            if not visited[n]:
                query[n] += cost
                visited[n] = True
                que.append(n)

bfs(tree, 0, n, query)
print(*query)


Measured memory_bytes: 104980
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <climits>

#define mod 1000000007
#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)

using namespace std;
using ll = long long;

int X[] = {-1, 0, 1, 1, 1, 0, -1, -1};
int Y[] = {1, 1, 1, 0, -1, -1, -1, 0};

void solve() {
    int n, a;
    cin >> n >> a;
    cout << pow(n,2)-a << endl;
}

int main(){
    solve();
    return 0;
}

Measured memory_bytes: 256
import sys
import math

n = int(input())
x = [0] * n
y = [0] * n

def init():
    global x, y
    for i in range(n):
        ss = sys.stdin.readline()
        cord = ss.split(' ')
        x[i] = int(cord[0])
        y[i] = int(cord[1])

a = [0] * n
used = [False] * n
m = 0
count = 0
def dist():
    global x, y, n
    sum = 0.0
    for i in range(n - 1):
        i0 = a[i]
        i1 = a[i + 1]
        sum += math.sqrt((x[i0] - x[i1]) ** 2 + (y[i0] - y[i1]) ** 2)
    return sum
def work(i):
    global m, count
    if i >= n:
        m += dist()
        count += 1
    else:
        for k in range(n):
            if not used[k]:
                used[k] = True
                a[i] = k
                work(i + 1)
                used[k] = False
        
init()
work(0)
print m / count




Measured memory_bytes: 2696
n = int(input())
xl = [list(map(int,input().split())) for _ in range(n)]

li = []
for x,l in xl:
    li.append([x-l,x+l])

li.sort(key = lambda x: x[1], reverse = False)

ans = 0
now = li[0][1]

for i in range(1,n):
    if li[i][0] < now:
        ans += 1
    else:
        now = li[i][1]

print(n - ans)


Measured memory_bytes: 42792
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import sys
def main(N, A):
    A.sort()
    s = 0
    dp = [0] * (N + 1)
    for i, a in enumerate(A):
        dp[i + 1] = 1
        if a <= s * 2: dp[i + 1] += dp[i]
        s += a
    print(dp[N])

if __name__ == '__main__':
    input = sys.stdin.readline
    N = int(input())
    *A, = map(int, input().split())
    main(N, A)


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

#define warn printf("!!!***!\n")
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
const int maxn=2e6+6;
const int mod=1e9+7;
const int oo=0x3fffffff;
char s[maxn];
int main()
{
     scanf("%s",s+1);
     int len=strlen(s+1);
     for(int i=1;i<=len;i++) printf("x");
     printf("\n");
     


}


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

void solve()
{
    int n, c; cin >> n >> c;
    vector<ll> dp(c + 1);
    for (int i = 0; i < n; ++i) {
        int w, v; cin >> w >> v;
        for (int j = c - w; j >= 0; --j) {
            dp[j + w] = max(dp[j] + v, dp[j + w]);
        }
    }
    cout << dp[c] << '\n';
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 3976
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

typedef long long LL;
const int MAX = 200000;
const LL MOD = 998244353;

long long fact[MAX];
long long inv[MAX];

LL mod_pow(LL x,LL n){
    LL ret = 1;

    while(n){
        if(n & 1)ret = ret * x % MOD;
        x = x * x % MOD;
        n /= 2;
    }

    return ret;
}

LL mod_P(int n,int k){
    if(n < k)return 0;
    return fact[n] * inv[n - k] % MOD;
}

LL mod_C(int n,int k){
    if(n < k)return 0;
    return mod_P(n,k) * inv[k] % MOD;
}

void init(){
    fact[0] = inv[0] = 1;
    for(int i = 1;i < MAX;i++){
        fact[i] = fact[i - 1] * i % MOD;
        inv[i] = mod_pow(fact[i],MOD - 2);
    }
}

int main(){
    init();
    int N,M,K;

    cin >> N >> M >> K;


    long long ans = 0;
    for(int i = 0;i <= K;i++){
        ans = (ans + (M * (mod_pow(M - 1,N - i - 1)) % MOD) * (mod_C(N - 1,i))) % MOD; 
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef string str;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

// I/O Asynchronizing
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

int main() {
    str s;
    cin >> s;
    s[3] = '8';
    cout << s << "\n";

    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val S = mutableListOf<String>()
    (1..N).forEach {
        S.add(readLine()!!)
    }

    val march = listOf('M', 'A', 'R', 'C', 'H')

    // O(N * 5)
    val sizes = march.map {char ->
        S.filter { it[0] == char }.size.toLong()
    }

    var answer = 0L
    // Each combination
    (0..4).forEach { i ->
        (i..4).forEach { j ->
            (j..4).forEach { k ->
                if(i != j && j != k) {
                    answer += sizes[i] * sizes[j] * sizes[k]
                }
            }
        }
    }
    println(answer)
}

Measured memory_bytes: 43452
import java.io.IOException;
import java.util.*;

/**
 */
class Main {
	public static void main(String[] args) throws IOException {
		Scanner in = new Scanner(System.in);

		while(in.hasNext()) {
			List<Integer> ai = new ArrayList<Integer>();
			List<Integer> bi = new ArrayList<Integer>();

			for(int i=0;i<4;i++) ai.add(in.nextInt());
			for(int i=0;i<4;i++) bi.add(in.nextInt());

			Map<Integer, Integer> hit = new HashMap<Integer, Integer>();
			for(int i=0;i<4;i++) {
				if(ai.get(i) == bi.get(i)) {
					hit.put(ai.get(i), 1);
				}
			}

			int blow = 0;
			for(int i=0;i<4;i++) {
				if(hit.containsKey(bi.get(i)) == false && ai.contains(bi.get(i))) {
					blow++;
				}
			}
			System.out.println(String.format("%d %d",hit.size(),blow));
		}
	}
}

Measured memory_bytes: 25920
#include <iostream>
using namespace std;
int main()
{
    int max=0;
    int num=101;
    int x;
    for(int i=0;i<4;i++)
    {
        cin>>x;
        if(x>max)  max=x;
         if (x<num) num=x;
    }
    cout<<max-num<<endl;
    return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//MOD
//--------------------------------------------
#define MUL(a,b) (((a) % MOD) * ((b) % MOD)) % MOD

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	VL Abs(n);
	VL v(n), c(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> c[i];
		Abs[i] = v[i] - c[i];
	}
	sort(RALL(Abs));
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (Abs[i] < 0) {
			break;
		}
		ans += Abs[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void);

int main(void)
{
    double r, S, L;
    double PI = 3.141592653589;
    /* 浮動小数点型の数値を読み込む場合、%dではなく%lfを使う */
    scanf("%lf", &r);

    S = r * r * PI;
    L = 2 * PI * r;

    printf("%.6lf %.6lf\n", S, L);
    return(0);
}


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

int main()
{
  int64_t N, a;
  cin >> N;
  map<int64_t, int64_t> mp;
  for (int i = 0; i < N; i++)
  {
    cin >> a;
    if (mp.count(a))
      mp.erase(a);
    else
      mp[a]++;
  }
  cout << mp.size() << endl;
}

Measured memory_bytes: 9800
import sys,collections
sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

Sp = S()
T = S()
S = ""
flag = True
for i in range(len(Sp)-len(T),-1,-1):
    if flag:
        for j in range(len(T)):
            if Sp[i+j] != "?" and T[j] != Sp[i+j]:
                break
            elif j == len(T)-1:
                S = Sp[0:i] + T + Sp[i+j+1:len(Sp)]
                flag = False
if S == "":
    print("UNRESTORABLE")
else:
    print(S.replace("?", "a"))


Measured memory_bytes: 3316
import java.util.Scanner;

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

    		 double a = sc.nextFloat();
    		 double b = sc.nextFloat();
    		 double sum = a + b;
    		 if(sum % 2 == 1) {
    			 sum++;
    		 }
    		 int average = (int)sum /2;
    			 System.out.println(average);
    	}
    }

Measured memory_bytes: 23252
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    K, N = input_nums()
    A = input_nums()
    dist = []
    for i in range(len(A)-1):
        dist.append(A[i+1]-A[i])
    dist.append(K+A[0]-A[-1])
    maxv = max(dist)
    print(sum(dist) - maxv)
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 26444
import sys
input = sys.stdin.readline

N, H = map(int, input().split())
a_max = 0
b = []

for _ in range(N):
    ai, bi = map(int, input().split())
    a_max = max(a_max, ai)
    b.append(bi)

b.sort(reverse=True)
ans = 0

for bi in b:
    if a_max>bi:
        break
    
    H -= bi
    ans += 1
    
    if H<=0:
        print(ans)
        exit()

ans += (H+a_max-1)//a_max

print(ans)

Measured memory_bytes: 46044
#include <stdio.h>
#include <algorithm>
int n;
long long a[100000];
long long b[100000];
long long c[100000];
long long s, ans;
int k;
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lld", a + i);
	}
	for (int i = 0; i < n; i++) {
		scanf("%lld", b + i);
	}
	for (int i = 0; i < n; i++) {
		c[i] = a[i] - b[i];
	}
	std::sort(c, c + n);
	for (int i = 0; i < n; i++) {
		if (c[i] < 0) {
			ans++;
			s += c[i];
		}
	}
	k = n - 1;
	while (s < 0) {
		ans++;
		s += c[k];
		if (k == 0) {
			printf("-1\n");
			return 0;
		}
		k--;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
    using namespace std;
    using std::cout;
    using std::endl;
    using std::string;
    #define sz(x) int(x.size())
    #define all(x) x.begin(), x.end()
    #define rall(x) x.rbegin(), x.rend()
    #define sqr(x) ((x) * (x))
    #define ft first
    #define sz(x) (int)x.size()
    #define yes cout<<"Yes\n"
    #define  no cout<<"No\n"
    #define all(x)x.begin(),x.end()
    #define rall(x)x.rbegin(),x.rend()
    #define sd second
    #define read(a)for(auto &qwqw:a)cin >> qwqw;
    #define print(a)for(auto qwqw:a)cout<<qwqw<<' ';
    #define print_plus(a)for(auto qwqw:a)cout<<qwqw+1<<' ';
    #define FOR(i, b, n) for(int i=b;i<n;i++)
    #define rep(i,x) for (int i = 0 ; i < x; ++i)
    #define rrep(i,x) for (int i = x - 1; i >= 0; --i)
    //#define int long long
    //mt19937_64 rnd(time(0));
    using ll = long long;
    using vi = vector<int>;
    using ld = long double;
    using vb = vector<bool>;
    using pii = pair<int, int>;
    using vd = vector<long double>;

    signed int main() {
        int d, t, s;
        cin >> d >> t >> s;
        if ((s * t) >= d)
            cout << "Yes";
        else
            cout << "No";
    }

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string a,b,c,ans;
	cin>>a;
	cin>>b;
	cin>>c;
	ans=a.substr(0,1)+b.substr(1,1)+c.substr(2,1);
	cout<<ans<<endl;
	return 0;

}

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

#define slld(longvalue) scanf("%lld", &longvalue)
#define plld(longvalue) printf("%lld\n", longvalue)

#define slf(longvalue) scanf("%lf", &longvalue)
#define plf(longvalue) printf("%lf\n", longvalue)
#define sc(letter) scanf("%c", &letter)
#define pc(letter) printf("%c", letter)

#define ss(name) scanf("%s", name)
#define ps(name) printf("%s", name)

#define pnew printf("\n")

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >
#define pii pair < int, int >

#define printcase(indexing,ans) printf("Case %lld: %lld\n", indexing, ans)

#define pb(x) push_back(x)

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

#define mod 1000000009


using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

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

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

    cin >> n;

    ll sum = 0;

    slld(testcase);

    for(ll cs = 1; cs <= testcase; cs++)
    {
        slld(input);

        sum += input;
    }

    if(sum >= n) cout << "Yes" << endl;
    else cout << "No" << endl;


}




Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

const Mod = 1000000007

var empty = byte('.')

func main() {
	var h, w int
	fmt.Scan(&h, &w)

	size := 1000000
	buf := make([]byte, size)
	sc := NewScanner(os.Stdin)
	sc.Buffer(buf, size)

	grid := make([][]byte, h)
	for i := 0; i < h; i++ {
		grid[i] = sc.Bytes()
	}

	var dp [1001][1001]int
	dp[0][0] = 1

	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if grid[i][j] != empty {
				continue
			}
			if i == 0 && j == 0 {
				dp[i][j] = 1
				continue
			}
			if i == 0 {
				dp[i][j] = dp[i][j-1]
				continue
			}
			if j == 0 {
				dp[i][j] = dp[i-1][j]
				continue
			}

			dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % Mod
		}
	}

	fmt.Println(dp[h-1][w-1])
}

type Scanner struct{ *bufio.Scanner }

func NewScanner(r io.Reader) *Scanner {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	return &Scanner{Scanner: s}
}

func (s *Scanner) Bytes() []byte { s.Scan(); return s.Scanner.Bytes() }


Measured memory_bytes: 9472
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e5+10,mod=1e9+7;
int n,k;
inline int read()
{
	int x=0,ff=1;
	char ch=getchar();
	while(!isdigit(ch)) {if(ch=='-') ff=-1;ch=getchar();}
	while(isdigit(ch)) {x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	return x*ff;
}
int main()
{
	//freopen("1.in","r",stdin);
	n=read();k=read();n++;
	ll ans=0;
	for(int i=k;i<=n;++i)
	{
		ll l=(ll)i*(i-1)/2;
		ll r=(ll)((n-i)+(n-1))*i/2;
		ans=(ans+r-l+1)%mod;
	}
	printf("%lld",ans);
	return 0;
}


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

int main(){
  int i,N;
  int l,r;
  int sum=0;
  cin >> N;

  for(int i=0;i<N;i++){
	cin >> l >> r; 
    if(l>r){
    	sum=sum+(l-r)+1;
    }
    else{
    sum=sum+(r-l)+1;
    }
  }
  cout << sum << endl;
}



Measured memory_bytes: 256
x,n=[int(x) for x in input().split()]
if n==0:
  print(x)
else:
  p=[int(x) for x in input().split()]
  ans=[]
  Flag=False
  while ans==[]:
    for i in range(105):
      if x-i not in p:
        ans.append(x-i)
        Flag=True
        break
      elif x+i not in p:
        ans.append(x+i)
        Flag=True
        break
    if Flag:
      break
  print(min(ans))

Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int h, w;
    cin >> h >> w;
    vvint c(10, vint(10));
    rep(i, 10) rep(j, 10) cin >> c[i][j];
    
    rep(k, 10) rep(i, 10) rep(j, 10) {
        c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
    }

    int ans = 0;
    int a;
    rep(i, h*w) {
        cin >> a;
        if (a >= 0) ans += c[a][1];
    } 

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

Measured memory_bytes: 256
#abc083 b-some sums
n,a,b=map(int,input().split())
num=[str(x) for x in range(1,n+1)]
ans=0
for x in num:
    s=0
    for y in range(len(x)):
        s+=int(x[y])
    if a<=s<=b:
        ans+=int(x)
print(ans)

Measured memory_bytes: 3572
N = int(input())
X = list(map(int, input().split()))
M = int(input())
A = list(map(int, input().split()))

for i in range(M) :
  num = A[i] - 1
  x = X[num]
  if(x + 1 in X or x == 2019) :
    pass
  else :
    X[num] = x + 1

for i in range(N) :
  print(X[i])


Measured memory_bytes: 5608
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b){ if(a < b) { a=b; return 1; }return 0;}
template<class T> inline bool chmin(T& a, T b){ if(a > b) { a=b; return 1; }return 0;}
const long long INF = 1LL << 60;

// --------write my code!!!!!----------//

int main(){
    int A,M; cin >> A >> M;
    // 余裕持って要素数50にした
    int num[50]={0};
    int bit[50]={0};
    rep(i,A){
        int x; cin >> x;
        rep(j,x){
            int y; cin >> y;
            num[y+1]++;
            if(num[y+1]==A) bit[y+1]++;
        }
    }
    int res = 0;
    rep(i,50) if(bit[i]) res++;
    cout << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int pow(int a, int b)
{
    int res = 1;
    rep(i, 0, b)
    {
        res *= a;
        res %= MOD;
    }
    return res;
}

void _main()
{
    COMinit();

    int N, K;
    cin >> N >> K;
    for (int i = 1; i <= K; ++i)
    {
        const int remainingRedNum = N - K - (i - 1);
        const int barNum = i;
        cout << COM(K - 1, i - 1) * COM(remainingRedNum + barNum, barNum) % MOD << endl;
    }
}


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

void solve(long long N, long long K, std::vector<long long> p){
    sort(p.begin(), p.end());
    ll ans = 0;
    for(ll i = 0; i < K; ++i) ans = ans + p[i];
    cout << ans << endl;
    return;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> p(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&p[i]);
    }
    solve(N, K, std::move(p));
    return 0;
}


Measured memory_bytes: 3708
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

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

  long long a, b;
  cin >> a >> b;

  vector<long long> x(n + 1);

  for (int i = 1; i <= n; i++)
    cin >> x[i];
  
  long long sum = 0;

  for (int i = 1; i < n; i++) {
    int dis = x[i + 1] - x[i];
    if (dis * a < b)
      sum += dis * a;
    else
      sum += b;
  }

  cout << sum << "\n";

  return 0;
}



Measured memory_bytes: 1024
#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, M;
  cin >> N >> M;
  
  vector<P> p(M); //firstでs,secondでcにアクセス
  rep(i,M)cin >> p[i].first >> p[i].second;
  
  rep(x,1000){
    int keta = 1;
    int nx = x/10;
    vector<int> d(1,x%10); //最初は１の位だけ入ってる
    while(nx){
      keta++;
      d.push_back(nx%10);
      nx /=10;
    }
    
    if(keta != N)continue;
    bool ok = true;
    reverse(d.begin(),d.end());
    rep(i,M){
      if(d[p[i].first -1] != p[i].second) ok = false;
    }
    if(ok){
      cout << x << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  
  
}


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

int64_t gcd(int64_t a, int64_t b) {
  if(a < b) return gcd(b, a);
  int64_t r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
int64_t lcm(int64_t a, int64_t b){
 return (a*b)/gcd(a,b);
}

int main(){
  int64_t A, B;
  cin >> A >> B;
  cout << lcm(A,B) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,a[100005];
ll ans = 0;
struct RMQ{
	pair<int,ll>seg[(1<<18)];
	void I(){ fill(seg,seg+(1<<18),mp(0,0)); }
	void init(int i,pair<int,ll>a){
		i += (1<<17)-1;
		seg[i] = max(seg[i],a);
		while(i){
			i = (i-1)/2;
			seg[i] = max(seg[i*2+1],seg[i*2+2]);
		}
	}
	pair<int,ll> query(int a,int b,int k,int l,int r){
		if(r<a||b<l||a>b) return mp(0,0);
		if(a<=l && r<=b) return seg[k];
		return max(query(a,b,k*2+1,l,(l+r)/2),query(a,b,k*2+2,(l+r)/2+1,r));
	}
	ll ans(){
		return seg[0].sc;
	}
}kaede;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		pair<int,ll>R = kaede.query(0,a[i],0,0,(1<<17)-1);
		kaede.init(a[i]+1,mp(R.fi+1,R.sc+a[i]));
	}
	cout << kaede.ans() << endl;
}


Measured memory_bytes: 7724
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
#define ll long long
const ll mod = 1e9 + 7;
ll n, k;
ll dp[2005][2005], C[2005][2005], jie[2005];
ll cal(ll x)
{
    return C[k - 1][x - 1] * C[n - k + 1][x] % mod;
}
void init()
{
    C[0][0] = 1;
    for (int i = 1; i <= 2004; ++ i)
    {
        C[i][0] = 1;
        for (int j = 1; j <= i; ++ j)
        {
            C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod;
        }
    }
    jie[1] = 1;
    for (ll i = 2; i <= 2004; ++ i)
    {
        jie[i] = i * jie[i - 1] % mod;
    }
    for (int i = 1; i <= 2004; ++ i)
        dp[i][1] = dp[i][0] = 1;
    for (int i = 1; i <= 2004; ++ i)
    {
        for (int j = 2; j <= i; ++ j)
        {
            dp[i][j] = (dp[i][j - 1] + dp[i - j][j]) % mod;
        }
    }
}
void slove()
{
    scanf("%lld %lld" ,&n ,&k);
    init();
    //cout << C[6][2] << ' ' << C[6][4] << endl;
    for (ll i = 1; i <= k; ++ i)
    {
        printf("%lld\n" ,cal(i));
    }
    return ;
}
signed main()
{
    slove();
    return 0;
}


Measured memory_bytes: 61696
#include <bits/stdc++.h>
#define ms(x, a) memset(x, a, sizeof(x))
#define oo 1000000000
#define ll long long int
#define MOD 1000000007
using namespace std;
typedef pair<ll,ll> ii ;
vector<ii>v;
ll  dp [100007];
ll cnt(ll sum){
    if(sum<=0)return 0;
    if(dp[sum]+1)return dp[sum];
    ll ans=oo;
    for(int i=0;i<v.size();i++){
        ans=min(ans,cnt(sum-v[i].first)+v[i].second);
    }
    return dp[sum]=ans ;
}
int main()
{
    int  n ,k ;
    cin>>n>> k;
    ms(dp,-1);
    for(int i = 0;i<k;i++){
        int a,b;
        cin>>a>>b;
        v.push_back({a,b});
    }
    cout<<cnt(n);
    return 0;
}






Measured memory_bytes: 1536
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, a, b) for (ll i = a; i < (ll)b; ++i)
#define digit(a) to_string(a).size()
#define INF 10e12
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

const long long MOD = 1e9 + 7;

int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int x, n;
    cin >> x >> n;
    set<int> st;
    rep(i, 0, n)
    {
        int tmp;
        cin >> tmp;
        st.insert(tmp);
    }
    if (n == 0)
    {
        cout << x << endl;
        return 0;
    }
    ll ans = INF;
    ll diff = INF;
    rep(i, -1, 102)
    {
        if (diff > abs(x - i) && find(all(st), i) == st.end())
            diff = abs(x - i), ans = i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3684
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <set>

using namespace std;


int main() {
	double n, k;
	cin >> n >> k;
	double res = 1, a, b;
	for (int i=0; i<n; ++i){
		a = res * 2;
		b = res + k;
		res = min(a, b);
	}
	cout << res << endl;
}

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

int main() {
  int A,B;
  cin >> A >>B;
  int count =0;

  
  if (A%10000/1000*10 + A/10000 >= A%100 ){
  	count ++;
  }
  if (B%10000/1000*10 + B/10000 <= B%100 ){
  	count ++;
  }

  
  A /= 100;
  B /= 100;
  count = count+ B-A-1;
  
   cout << count << endl;

}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll N,M;

ll ok(ll v) {
	if(M-2*v<0) return 0;
	if(N+(M-2*v)/2<v) return 0;
	return 1;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	
	ll ret=0;
	for(i=50;i>=0;i--) if(ok(ret+(1LL<<i))) ret+=1LL<<i;
	cout<<ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
int main()
{
    map<char, char> m;
    m['A'] = 'T';
    m['T'] = 'A';
    m['G'] = 'C';
    m['C'] = 'G';
    char c;
    cin >> c;
    cout << m[c] << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 1000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;

int ans;
string s;
int n,a[111111],b[111111],c[111111];
int dp[111111][3];
signed main(){
	 cin>>n;
	 rep(i,n){
	 	cin>>a[i]>>b[i]>>c[i];
	 }
	 rep(i,n){
	 	dp[i+1][0]=max(dp[i][1]+a[i],dp[i][2]+a[i]);
	 	dp[i+1][1]=max(dp[i][0]+b[i],dp[i][2]+b[i]);
	 	dp[i+1][2]=max(dp[i][0]+c[i],dp[i][1]+c[i]);
	 }
	 cout<<max({dp[n][1],dp[n][0],dp[n][2]});
}


Measured memory_bytes: 5248
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

public class Main {

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

        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    public static class Task {

        public void solve(int testNumber, InputReader in, PrintWriter out) throws IOException {
            int x = in.nextInt();
            int y = in.nextInt();

            out.println(x % y == 0 ? "-1" : x);

        }

    }
//  }  ----------------------------------------------------------------------------
    // MAIN - INPUT - OUTPUT 

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public Double nextDouble() {
            return Double.parseDouble(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int[] nextIntArray(int arraySize) {
            int array[] = new int[arraySize];

            for (int i = 0; i < arraySize; i++) {
                array[i] = nextInt();
            }

            return array;
        }

        public char[][] nextMatrix(int row, int col) {

            char[][] m = new char[row][col];

            for (int i = 0; i < row; i++) {

                m[i] = next().toCharArray();
            }
            return m;
        }

    }
}


Measured memory_bytes: 21460
#include <stdio.h>
int main (void){
    int how_data;
    int x=0;
    int max=0;
    scanf("%d\n",&how_data);
    int loop1;
    for(loop1=0;loop1<how_data;loop1++){
        char temp;
        scanf("%c",&temp);
        if(temp=='I'){
            x++;
        }else{
            x--;
        }
        if(x>max){
            max=x;
        }
    }
    printf("%d\n",max);
    return 0;
    
}


Measured memory_bytes: 256
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn main() {
    input! {
        h: usize,
        w: usize,
        ab: [(Usize1, Usize1); h],
    }

    let mut start = BTreeMap::new();
    let mut moves = BTreeSet::new();
    for j in 0..w {
        start.insert(j, j);
        moves.insert((0, j));
    }
    for i in 0..h {
        let (ai, bi) = ab[i];
        let mut keys = vec![];
        for (&k, _) in start.range(ai..=bi) {
            keys.push(k);
        }
        if !start.contains_key(&(bi + 1)) && !keys.is_empty() && bi + 1 < w {
            start.insert(bi + 1, start[&keys[keys.len() - 1]]);
            moves.insert((bi - start[&(bi + 1)] + 1, bi + 1));
        }
        for &k in &keys {
            let v = start[&k];
            start.remove(&k);
            moves.remove(&(k - v, k));
        }
        // eprintln!("{:?}", start);
        // eprintln!("{:?}", moves);
        if let Some((d, _)) = moves.range(..).nth(0) {
            println!("{}", i + d + 1);
        } else {
            println!("-1");
        }
    }
}


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

//全員、「初期ポイント-問題数」してから、正解した人に「+1」する！

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int participants = sc.nextInt();
		int point = sc.nextInt();
		int questions = sc.nextInt();

		//正解した人の番号を入力
		int winner[] = new int[questions];
		for(int i=0 ; i<winner.length ; i++) {
			winner[i] = sc.nextInt();
		}

		//全員の初期ポイントを「ポイント－問題数」にする
		int result[] = new int[participants];
		Arrays.fill(result, point-questions);

		//正解した人にだけ「+1ポイント」する
		for(int i=0 ; i<questions ; i++) {
			result[winner[i]-1]++;
		}

		//result[]の値が0より大きいか判断
		for(int i : result) {
			System.out.println(i>0 ? "Yes" : "No");
		}
		sc.close();
	}
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

int main()
{
	int r,g;
	cin >> r >> g;
	cout << g+g-r << endl;

	return 0;
}

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

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N=one_int()
flg=False
for i in range(1,10):
    if (N/i).is_integer():
        if 1<= int(N//i) <= 9:
            flg=True
if flg:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
import bisect
N=int(input())
S=list(input())
ans=0
R=[]
G=[]
B=[]
for i in range(N):
    if S[i]=="R":
        R.append(i+1)
    elif S[i]=="G":
        G.append(i+1)
    else:
        B.append(i+1)
ans=len(B)*len(R)*len(G)
B.append(10000)
for r in R:
    for g in G:
        left=min(r,g)-abs(r-g)
        right=max(r,g)+abs(r-g)
        if (r+g)%2==0:
            middle=(r+g)//2
        else:
            middle=0
        for i in (left,right,middle):
            if i>0:
                a=bisect.bisect_left(B,i)
                if B[a]==i:
                    ans=ans-1
print(ans)

Measured memory_bytes: 74280
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long int
#define v vector<ll>
#define vv vector<v>
ll MOD=1e9+7;
int main() 
{ 
	int n,k;
	cin>>n>>k;
	v h(n+1,0),dp(n+1,1e9);
	dp[1]=0;
	cin>>h[1];
	for (int i=2; i<=n; i++)
	{
		cin>>h[i];
		for (int j=i-1; j>=max(1,i-k); j--)
			dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
	}
	cout<<dp[n];
    return 0;
} 

Measured memory_bytes: 1792
N = int(input())
D = list(map(int, input().split()))
S = 0
Ans = 0

for i in range(N):
  S = S + D[i]

for i in range(N):
  Ans = Ans + D[i] * (S - D[i])

Ans = Ans // 2

print(Ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n, m, q;
    cin >> n >> m >> q;
    vector<vector<int>> vlr(n+1,vector<int>(n+1));

    REP(i,m) {
        int l, r;
        cin >> l >> r;
        vlr[l][r]++;
    }

    vector<vector<int>> slr(n+1,vector<int>(n+1));
    FOR(i,1,n+1) FOR(j,1,n+1) {
        slr[i][j] = slr[i-1][j] + slr[i][j-1] - slr[i-1][j-1] + vlr[i][j]; 
    }

    REP(i,q) {
        int l, r;
        cin >> l >> r;
        int ans = slr[r][r] - slr[r][l-1] - slr[l-1][r] + slr[l-1][l-1];
        cout << ans << '\n';
    }

    return 0;
}

Measured memory_bytes: 2944
#include <vector>
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

const int N = 100005;
const int M = 100005;

vector<pair<int, int>> edges;
int a[N];
int parents[N];
long long weight[N];
bool included[M];
bool used[M];
bool visited[N];
int u[M], v[M], w[M];
vector<pair<int, int>> adj[N];

int find(int a) {
    if (parents[a] == a) return a;
    int pa = find(parents[a]);
    parents[a] = pa;
    return pa;
}

void join(int a, int b) {
    int pa = find(a);
    int pb = find(b);
    parents[pb] = pa;
    weight[pa] += weight[pb];
}

void dfs(int i, int wi) {
    visited[i] = true;
    for (auto& p : adj[i]) {
        if (used[p.second]) continue;
        if (w[p.second] <= wi) {
            used[p.second] = true;
            dfs(p.first, wi);
        }
    }
}

int main() {
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> weight[i];
        parents[i] = i;
    }

    for (int i = 0; i < m; i++) {
        int ui, vi, wi;
        cin >> ui >> vi >> wi;
        ui--;
        vi--;
        edges.push_back({wi, i});
        w[i] = wi;
        u[i] = ui;
        v[i] = vi;
        adj[ui].push_back({vi, i});
        adj[vi].push_back({ui, i});
    }

    sort(edges.begin(), edges.end());
    memset(included, false, sizeof(included));

    for (int i = 0; i < m; i++) {
        int idx = edges[i].second;
        int wi = edges[i].first;
        int pu = find(u[idx]);
        int pv = find(v[idx]);
        if (pu != pv) {
            join(pu, pv);
        }
        if (weight[find(pu)] >= wi) {
            included[idx] = true;
        }
    }

    memset(used, false, sizeof(used));
    memset(visited, false, sizeof(visited));
    for (int i = m - 1; i >= 0; i--) {
        int idx = edges[i].second;
        int wi = edges[i].first;
        if (used[idx]) continue;
        if (included[idx]) {
            dfs(u[idx], wi);
        }
    }

    int ans = m;

    for (int i = 0; i < m; i++) {
        if (used[i]) ans--;
    }
    cout << ans;
}


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

string s;

void solve(){
	stack<char> T;
	for(int i=0;i<s.size();i++){
		if(s[i]=='(' || s[i]=='[')
			T.push(s[i]);
		if(s[i]==')'){
			if(T.empty()){cout<<"no"<<endl;return;}
			if(T.top()=='(') T.pop();
			else{cout<<"no"<<endl;return;}
		}
		if(s[i]==']'){
			if(T.empty()){cout<<"no"<<endl;return;}
			if(T.top()=='[') T.pop();
			else{cout<<"no"<<endl;return;}
		}
	}
	if(T.empty())
		cout<<"yes\n";
	else cout<<"no\n";
}


int main(){

	while(getline(cin,s)){
		if(s==".") break;
		solve();
	}
	return 0;
}

Measured memory_bytes: 900