akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main() {
	int N; cin >> N;
	int ans = 0, nxt;
	cin >> nxt;
	int j;
	for(int i = 1, lst; i < N; ) {
		j = i;
		do {
			lst = nxt;
			cin >> nxt;
		} while(lst >= nxt && ++j < N);
		ans = max(ans, j - i);
		i = j + 1;
	}
	cout << ans << '\n';
}


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

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

    int a[N+1];
    for(int i = 1; i <= N; i++) cin >> a[i];

    int DP[K+1];
    for(int i = 0; i <= K; i++)
    {
        DP[i] = 0;
        for(int j = 1; j <= N; j++)
        {
            if(i < a[j]) break;
            DP[i] |= !DP[i - a[j]];
        }
    }
    cout << (DP[K] ? "First" : "Second") << '\n';
    return 0;
}

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

long C(long x){
    return (x*(x-1))/2;
}

int main(){
    int n;
    cin>>n;
    vector<string> v(n);
    vector<int> res;
    for(int i=0;i<n;i++){
        cin>>v[i];
        sort(v[i].begin(), v[i].end());
    }

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

    int cnt = 1;
    string base = v[0];

    for(int i=1; i<n ;i++){
        if(v[i] == base){
            cnt++;
        }
        else{
            res.push_back(cnt);
            cnt = 1;
            base = v[i];
        }

        if(i == n-1){
            res.push_back(cnt);
        }
    }

    long result = 0;

    for(int i=0 ;i<res.size(); i++){
        long x = (long) res[i];
        //cout<<"x "<<x<<endl;
        long temp = C(x);
        //cout<<temp<<endl;
        result += temp;
    }

    cout<<result<<endl;

    return 0;
}


Measured memory_bytes: 7936
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
const int MOD=(int)1e9+7;
long dp[210000][5],i,j,L;
string S;
void mod_add(long &a,long b){
  a+=b;
  if(a>=MOD)a-=MOD;
}
int main(){
  cin>>S;
  memset(dp,0,sizeof(dp));
  dp[0][0]=1;
  L=S.size();
  for(i=0;i<L;++i){
    for(j=0;j<5;++j) {
      if(S[i]!='?')mod_add(dp[i+1][j],dp[i][j]);
      else mod_add(dp[i+1][j],dp[i][j]*3%MOD);
    }
    if(S[i]=='A'||S[i]=='?')mod_add(dp[i+1][1],dp[i][0]);
    if(S[i]=='B'||S[i]=='?')mod_add(dp[i+1][2],dp[i][1]);
    if(S[i]=='C'||S[i]=='?')mod_add(dp[i+1][3],dp[i][2]);
  }
  cout<<dp[L][3]<<endl;
}


Measured memory_bytes: 8704
#include<cstdio>
#include<cstring>
#define int long long
int f[50][50][50],n,N,ans;
char s[50][50];
int dp(int l,int r,int mid){
	if(f[l][r][mid]!=-1)return f[l][r][mid];
	if(l==r)return f[l][r][mid]=1;
	if(l==mid||mid==r)return f[l][r][mid]=0;
	int ans=0;
	for(int j=l;j<=mid-1;j++)
		for(int k=mid+1;k<=r;k++)
			if(s[j][k]=='1')
				for(int p=j;p<=mid-1;p++)
					for(int q=mid+1;q<=k;q++)
						ans+=dp(l,p,j)*dp(p+1,q-1,mid)*dp(q,r,k);
	return f[l][r][mid]=ans;
}
signed main(){
	scanf("%lld",&n);
	N=2*n;
	for(int i=1;i<=N;i++)
		scanf("%s",s[i]+1);
	memset(f,-1,sizeof(f));
	for(int i=2;i<=N;i++)
		if(s[1][i]=='1')
			ans+=dp(2,N,i);
	printf("%lld\n",ans);
	return 0;		
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int z,w;
int a[2002];
int dp[2002][2];

int func(int v,int p,int s){
	if(dp[v][s]!=-1){
		return dp[v][s];
	}
	int ans=abs(a[n-1]-w);
	if(v>0)ans=abs(a[n-1]-a[v-1]);
	for(int i=v;i<n-1;i++){
		int val=func(i+1,v,1-s);
		if(s==0)ans=max(ans,val);
		else ans=min(ans,val);
	}
	return (dp[v][s]=ans);
}

int main(void){
	scanf("%d",&n);
	scanf("%d%d",&z,&w);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	memset(dp,-1,sizeof(dp));
	printf("%d\n",func(0,0,0));
	return 0;
}

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

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

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;
int N;
bool One = false;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    int g = 0;
    for(int i = 0; i < N; i++) {
        int a;
        cin >> a;
        g ^= a;
        if(a & 1) One = true;
    }
    if(g == 1) cout << "Bob" << endl;
    else if(g == 0 and !One) cout << "Bob" << endl;
    else cout << "Alice" << endl;
    return 0;
}


Measured memory_bytes: 3216
#include <cstdio>

int main() {
  int a, b;

  scanf("%d %d", &a, &b);
  int sum = a + b;
  int sub = a - b;
  int mul = a * b;
  if (sum > sub) {
    if (sum > mul) printf("%d", sum);
    else printf("%d", mul);
  } else {
    if (sub > mul) printf("%d", sub);
    else printf("%d", mul);
  }

  return 0;
}

Measured memory_bytes: 128
N = int(input())
hlist = list(map(int, input().split()))

dp = [0]*N
dp[0] = 0
dp[1] = abs(hlist[1] - hlist[0])

for i in range(2, N):
    dp[i] = min(dp[i-1] + abs(hlist[i] - hlist[i-1]),
                dp[i-2] + abs(hlist[i] - hlist[i-2]))


print(dp[N-1])


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

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

#define pb push_back

const int INF = 100100100;
const int MOD = (int)1e9 + 7;

using ll = long long;

using namespace std;

int main(){

  int n;
  set<int> st;
  int tmp;

  cin >> n;
  REP( i, n){
    cin >> tmp;
    auto itr = st.find(tmp);
    if( itr == st.end() ){
      st.insert(tmp);
    }else{
      st.erase(itr);
    }
  }
  cout << st.size() << endl;
}






Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;
const double PI = acos(-1);

int main()
{
	int n;
	cin >> n;
	map<ll, ll> mp;
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		ll a;
		cin >> a;
		mp[a]++;
		sum += a;
	}
	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		ll b, c;
		cin >> b >> c;
		if (mp[b] != 0) {
			ll num = mp[b];
			mp[c] += num;
			mp[b] = 0;
			sum = sum - b * num + c * num;
			cout << sum << endl;
		}
		else cout << sum << endl;
	}
}


Measured memory_bytes: 9244
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = ip(br.readLine());
        int[] list = createListInt(br.readLine());
        selectionSort(list, n);

    }

    static void selectionSort(int[] list, int n) {
        int count = 0;
        for (int i = 0; i < n; i++) {
            int minj = i;
            for (int j = i + 1; j < n; j++) {
                if (list[j] < list[minj]) {
                    minj = j;
                }
            }
            if (i != minj) {
                swap(list, i, minj);
                count++;
            }
        }
        print(list);
        System.out.println(count);
    }

    static void bubbleSort(int[] list, int n) {
        int count = 0;
        boolean flag = true;
        while (flag) {
            flag = false;
            for (int i = n - 1; i > 0; i--) {
                if (list[i] < list[i - 1]) {
                    swap(list, i, i - 1);
                    flag = true;
                    count++;
                }
            }
        }
        print(list);
        System.out.println(count);
    }

    private static void print(int[] list) {
        int n = list.length;
        for (int i = 0; i < n; i++) {
            System.out.print(list[i]);
            if (i < n - 1) {
                System.out.print(" ");
            }
        }
        System.out.println();
    }

    static void swap(int[] list, int a, int b) {
        int temp = list[a];
        list[a] = list[b];
        list[b] = temp;
    }

    static int[] createListInt(String line) {
        String[] lines = line.split(" ");
        int n = lines.length;
        int[] list = new int[n];
        while (n-- > 0) {
            list[n] = Integer.parseInt(lines[n]);
        }
        return list;
    }

    static long[] createListLong(String line) {
        String[] lines = line.split(" ");
        int n = lines.length;
        long[] list = new long[n];
        while (n-- > 0) {
            list[n] = Long.parseLong(lines[n]);
        }
        return list;
    }

    static int ip(String s) {
        return Integer.parseInt(s);
    }

    static long lp(String s) {
        return Long.parseLong(s);
    }
}

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

int main() {
	int v1, v2;
	int l[10];
	int ls;
	char c;
	while (cin >> l[0] >> c) {
		for (int i=1; i<10; i++)
			cin >> l[i] >> c;
		cin >> v1 >> c >> v2;

		ls = 0;
		for (int i=0; i<10; i++)
			ls += l[i];
		
		double in = ((double)v1)/(v1+v2)*ls;
		int dis = 0;
		for (int i=0; i<10; i++) {
			dis += l[i];
			if ((double)dis >= in) { cout << i+1 << endl; break; }
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int arr[n+1];
	int count=0;
	for(int i=1;i<=n;i++)
	{
		cin>>arr[i];
		if(i%2==1 && arr[i]%2==1)
			count++;
	}
	cout<<count<<endl;
	return 0;
}

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

namespace SCC {
	const int N = 110000;
	vector<int> con[N], rcon[N];
	int n, vis[N], visT;
	int id[N], idn;
	void init(int nn = 0) {
		n = nn, visT = idn = 0;
		for (int i = 1; i <= n; i++) con[i].clear(), rcon[i].clear();
	}
	void add_edge(int u, int v) {
		con[u].push_back(v);
		rcon[v].push_back(u);
	}
	void dfs(int u) {
		vis[u] = 1;
		for (int v : con[u]) if (!vis[v]) dfs(v);
		id[idn++] = u;
	}
	void rdfs(int u) {
		vis[u] = visT;
		for (int v : rcon[u]) if (!vis[v]) rdfs(v);
	}
	void SCC() {
		for (int i = 1; i <= n; i++) vis[i] = 0;
		for (int i = 1; i <= n; i++) if (!vis[i]) dfs(i);
		for (int i = 1; i <= n; i++) vis[i] = 0;
		for (int i = idn - 1; i >= 0; i--) if (!vis[id[i]]) visT++, rdfs(id[i]);
	}
};

const int N = 1100;
const int M = 220000;

vector<int> con[N];

struct Edge {
	int u, v;
	Edge(int u = 0, int v = 0) : u(u), v(v) {}
} E[M];

int adj[N][N];
int vis[N], visT;
int son[2][N][N];

inline bool Find(int u, int tar) {
	if (adj[u][tar] > 1) return true;
	return son[0][u][tar] != tar || son[1][u][tar] != tar;
}

void dfs(int u, int id, int rt, int __rt) {
	vis[u] = visT;
	son[id][__rt][u] = rt;
	for (int v : con[u]) if (vis[v] != visT) dfs(v, id, rt, __rt);
}

void init(int n) {
	for (int i = 1; i <= n; i++) {
		visT++;
		vis[i] = visT;
		for (int v : con[i]) if (vis[v] != visT) dfs(v, 0, v, i);
		reverse(con[i].begin(), con[i].end());
		visT++;
		vis[i] = visT;
		for (int v : con[i]) if (vis[v] != visT) dfs(v, 1, v, i);
	}
}

int main() {
	
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	int n, m; cin >> n >> m;
	SCC::init(n + 10);
	for (int i = 0; i < m; i++) {
		int u, v; cin >> u >> v;
		E[i] = Edge(u, v);
		con[u].push_back(v);
		adj[u][v]++;
		SCC::add_edge(u, v);
	}
	SCC::SCC();
	
	init(n);
	
	for (int i = 0; i < m; i++) {
		auto a = SCC::vis[E[i].u], b = SCC::vis[E[i].v];
		if (a == b) {
			if (Find(E[i].u, E[i].v)) cout << "same\n";
			else cout << "diff\n";
		} else {
			if (Find(E[i].u, E[i].v)) cout << "diff\n";
			else cout << "same\n";
		}
	}
	
	return 0;
}

Measured memory_bytes: 27520
#include<cstdio>
#define MAX 10000
#define NIL -1

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

Node T[MAX];
int n,D[MAX],H[MAX];

void setDepth(int u,int d){
  if(u==NIL)return;
  D[u]=d;
  setDepth(T[u].left,d+1);
  setDepth(T[u].right,d+1);
}
int setHeight(int u){
  int h1=0,h2=0;
  if(T[u].left!=NIL)
    h1 = setHeight(T[u].left) + 1;
  if(T[u].right!=NIL)
    h2 = setHeight(T[u].right) + 1;
  return H[u] = (h1 > h2 ? h1 : h2);
}
int getSibling(int u){
  if(T[u].parent == NIL)return NIL;
  if(T[T[u].parent].left != u && T[T[u].parent].left != NIL)
    return T[T[u].parent].left;
  if(T[T[u].parent].right != u && T[T[u].parent].right != NIL)
    return T[T[u].parent].right;
  return NIL;
}
void print(int u){
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",getSibling(u));
  int deg = 0;
  if(T[u].left != NIL)deg++;
  if(T[u].right != NIL)deg++;
  printf("degree = %d, depth = %d, height = %d, ",deg,D[u],H[u]);
  if(T[u].parent==NIL){
    printf("root\n");
  }
  else if(T[u].left == NIL && T[u].right == NIL){
    printf("leaf\n");
  }
  else{
    printf("internal node\n");
  }
}
int main(){
  int v,l,r,root = 0;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    T[i].parent = NIL;
  }
  for(int i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    T[v].left = l;
    T[v].right = r;
    if(l != NIL)T[l].parent = v;
    if(r != NIL)T[r].parent = v;
  }
  for(int i=0;i<n;i++)if(T[i].parent == NIL)root = i;
  setDepth(root,0);
  setHeight(root);
  for(int i=0;i<n;i++)print(i);
  return 0;
}



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

int main(){
	int n,x;
	cin>>n;
	vector <int> v;
	for (int i=0;i<n;i++){
		cin>>x;
		v.push_back(x);
	}
	sort(v.begin(),v.end());
	
	/*
	for(int i=0;i<n;i++){
		cout<<v[i]<<" ";
	}
	*/
	int duplicate=0,no=0;
	for (int i=0;i<n;){
		if (v[i]==v[i+1]){
			duplicate++;
			i+=2;
		}
		else{
			i++;
			no++;
		}		
	}
	cout<<no<<endl;
	
	return 0;
}

Measured memory_bytes: 3912
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N + 2];
		
		A[0] = 0;
		A[N + 1] = 0;
		
		for (int i = 1; i <= N; i++) {
			A[i] = sc.nextInt();
		}
		
		int originalCost = 0;
		for (int i = 1; i < A.length; i++) {
			originalCost += Math.abs(A[i] - A[i - 1]);
		}
		
		for (int i = 1; i <= N; i++) {
			int cost = originalCost;
			cost -= (Math.abs(A[i] - A[i - 1]) + Math.abs(A[i] - A[i + 1]));
			cost += Math.abs(A[i + 1] - A[i - 1]);
			System.out.println(cost);
		}
	}
}

Measured memory_bytes: 63896
S = list(input())

list = [0]
for i in range(len(S)):
    count = 0
    if S[i] == "A" or S[i] == "T" or S[i] == "C" or S[i] == "G":
        count = 1 + list[i]
    list.append(count)

print(max(list))


Measured memory_bytes: 2940
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i): is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
def prime_factor(n):
    """Return a list of prime factorization numbers of n"""
    res = []
    for i in range(2,int(n**0.5)+1):
        while n%i==0: res.append(i); n //= i
    if n != 1: res.append(n)
    return res
## libs ##
from itertools import accumulate as acc, combinations as combi, product, combinations_with_replacement as combi_dup
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#
def pprint(c):
    for ci in c:
        print(*ci)

def main():
    h, w = MII()
    n = II()
    aa = MII()
    aa = deque([i+1 for i, a in enumerate(aa) for _ in range(a)])
    if w == 1:
        print(*aa, sep='\n')
        return None
    c = DD2(h,w)
    for i in range(h):
        if not aa: break
        for j in range(i,w-i): # to right
            c[i][j] = aa.popleft()
        if not aa: break
        for k in range(i+1, i+1+(h-2*(i+1))): # to down
            c[k][w-1-i] = aa.popleft()
        if not aa: break
        for j in reversed(range(i,w-i)): # to left
            c[h-1-i][j] = aa.popleft()
        if not aa: break
        for k in reversed(range(i+1, i+1+(h-2*(i+1)))): # to up
            c[k][i] = aa.popleft()
    for ci in c:
        print(*ci)



if __name__ == '__main__':
    main()

Measured memory_bytes: 4324
[N,K,S] = list(map(int,input().split()))
cnt = 0
if S != 1:
    output = []
    for i in range(K):
        output.append(S)
    for i in range(N-K):
        cnt += 1
        if cnt < S:
            output.append(1)
        else:
            output.append(S+1)
            cnt = 0
else:
    output = []
    for i in range(K):
        output.append(S)
    for i in range(N-K):
        output.append(2)

print(" ".join(map(str, output)))

Measured memory_bytes: 66208
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int N, C; cin >> N >> C;
    vector<vector<int>> ds(C, vector<int>(C)), cs(N, vector<int>(N));
    for (int i = 0; i < C; ++i)
    {
        for (int j = 0; j < C; ++j)
        {
            cin >> ds[i][j];
        }
    }
    for (int i = 0; i < N; ++i)
    {
        for (int j = 0; j < N; ++j)
        {
            int ci;  cin >> ci; cs[i][j] = ci - 1;
        }
    }
    // 良いグリッドは３色，C<=30なので色の選び方は高々 30C3 < 27000
    // ->前処理で各選び方についてO(1)で違和感の総和を計算できるようにする
    // diffs[i][j][c]:(i,j)をcに変えたときの違和感:O(N^2*C)
    vector<vector<vector<int>>> diffs(N, vector<vector<int>>(N, vector<int>(C)));
    for (int i = 0; i < N; ++i)
    {
        for (int j = 0; j < N; ++j)
        {
            for (int c = 0; c < C; ++c)
            {
                diffs[i][j][c] = ds[cs[i][j]][c];
            }
        }
    }
    // sums[r][c]:r=(i+j)%3をcで塗ったときの違和感の総和:O(N^2*C)
    vector<vector<int>> sums(3, vector<int>(C, 0));
    for (int i = 0; i < N; ++i)
    {
        for (int j = 0; j < N; ++j)
        {
            for (int c = 0; c < C; ++c)
            {
                sums[(i + j) % 3][c] += diffs[i][j][c];
            }
        }
    }
    // 全ての色の組み合わせを試す:O(C^3)
    int ans = 1000 * 500 * 500;
    for (int c1 = 0; c1 < C; ++c1)
    {
        for (int c2 = 0; c2 < C; ++c2)
        {
            for (int c3 = 0; c3 < C; ++c3)
            {
                if (c1 != c2 && c2 != c3 && c3 != c1)
                {
                    int sum = sums[0][c1] + sums[1][c2] + sums[2][c3];
                    ans = min(ans, sum);
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 38400
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 998244353 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

N,A,B,K = map(int, input().split())
ans = 0
for i in range(N+1):
  if (K-A*i)%B!=0:
    continue
  j = (K-A*i)//B
  m = cmb(N,i,mod)*cmb(N,j,mod)%mod
  ans += m
  ans %= mod
print(ans)

Measured memory_bytes: 127560
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int cur=0,mx=0,len;
    string s;
    cin>>len>>s;
    for(int i=0;i<s.length();i++){
        if(s[i]=='I')
            cur++;
        else
            cur--;
        mx=max(mx,cur);
    }
    cout<<mx<<endl;
    return 0;
}


Measured memory_bytes: 3628
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

//#include<bits/stdc++.h>


using namespace std;


int main() {

	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a*b >= c*d)cout << a*b << endl;
	else cout << c*d << endl;
	

	return 0;

}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (ll i = (ll)(start); i < (ll)(n); ++i)
static const ll INFTY = 1L << 62L;
ll solver()
{
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    ll v[n + 1] = {};
    ll a, b;
    rep(i, 0, m)
    {
        cin >> a >> b;
        ++v[a], ++v[b];
    }
    ll ans = true;
    rep(i, 1, n + 1)
    {
        if (v[i] % 2)
        {
            ans = false;
            break;
        }
    }
    if (ans)
        cout << "YES\n";
    else
    {
        cout << "NO\n";
    }
}

Measured memory_bytes: 4372
#include <iostream>
#include <list>

int main()
{
	std::list<int> gets ;
	int get ;

	for( int i = 0 ; i < 5 ; i ++ )
	{
		std::cin >> get ;

		if( gets.empty() )	gets.push_front( get ) ;
		else
		{
			std::list<int>::iterator i = gets.begin() ;
			while( i != gets.end() )
			{
				if( get >= *i )
				{
					gets.insert( i , get ) ;
					break ;
				}
				else	*i ++ ;
			}
			if( i == gets.end() )	gets.push_back( get ) ;
		}
	}

	for( std::list<int>::iterator i = gets.begin() ; i != gets.end() ; )
	{
		std::cout << *i++ ;
		if( i == gets.end() )	break ;
		else					std::cout << " " ;
	}
	std::cout << std::endl ;

	return 0 ;
}

Measured memory_bytes: 1192
s=input()
#><となるところを見つける<<となるところを見つける>>となるところを見つける<>となるところについて考える
n=len(s)
ans=[0]*(n+1)

#左から>>となる部分を探す
for i in range(n):
    if s[i]=='<':
        ans[i+1]=max(ans[i+1],ans[i]+1)

for i in range(n-1,-1,-1):
    if s[i]=='>':
        ans[i]=max(ans[i],ans[i+1]+1)
print(sum(ans))

Measured memory_bytes: 29112
#include <iostream>
using namespace std;
int main() {
	int a, b;
	while(1) {
		cin >> a >> b;
		if (a == 0 && b == 0) break;
		if (a > b) {
			int temp = a;
			a = b;
			b = temp;
		}
		cout << a << " " << b << endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)

/* exchange */
#define chmin(a, b) (a) = min((ll)(a), (ll)(b))
#define chmax(a, b) (a) = max((ll)(a), (ll)(b))

/* output */
#define I(x) cin >> x;
#define D(x) cerr << (x) << " ";
#define BR cerr << "\n";
#define P(x) cout << (x) << endl;
#define FIX cout << fixed << setprecision(10);

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll ret = 0;
string S;
ll A, B, C;

int main(void){
  
  I(N);

  P(N+N*N+N*N*N);

}


Measured memory_bytes: 3672
#include<iostream>
#include<vector>
#include<algorithm>
#include<iterator>
#include<functional>
using namespace std;
using namespace placeholders;

using math = int;

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

        vector<math> A;
        A.reserve(M);
        copy_n(istream_iterator<math>{cin}, M, back_inserter(A));

        auto ap = bind(less<math>{}, _1, X);
        size_t cost_to0 = count_if(A.begin(), A.end(), ap);
        cout << min(cost_to0, M-cost_to0) << endl;

        return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

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

        String S = sc.next();

        System.out.println(solve(S));

        sc.close();
    }

    static String solve(String S) {
        return S.equals("ABC") ? "ARC" : "ABC";
    }
}

Measured memory_bytes: 35380
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

ll frac[100005];

ll comb(ll a, ll b) {
  if(a<b) return 0;
  ll ue = frac[a];
  ll shita1 = 1, shita2 = 1;
  ll tmpshita1, tmpshita2;
  ll h = mod - 2;
  ll two;
  while(h>0) {
    two = 1;
    tmpshita1 = frac[b];
    tmpshita2 = frac[a-b];
    while(2*two<h) {
      two *= 2;
      tmpshita1 *= tmpshita1;
      tmpshita2 *= tmpshita2;
      tmpshita1 %= mod;
      tmpshita2 %= mod;
    }
    h -= two;
    shita1 *= tmpshita1;
    shita2 *= tmpshita2;
    shita1 %= mod;
    shita2 %= mod;
  }
  return ue*shita1%mod*shita2%mod;
}

int main() {
  frac[0] = 1;
  for(ll i=1;i<100005;++i) {
    frac[i] = frac[i-1]*i%mod;
  }
  int N;
  cin>>N;
  int a[N+1];
  int A=0, B=0, C=0;
  map<int, int> amap;
  int now = 0;
  for(int i=0;i<N+1;++i) {
    cin>>a[i];
    amap[a[i]]++;
  }
  int point;
  for(int i=1;i<=N;++i) {
    if(amap[i]>1) point = i;
  }
  for(int i=0;i<N+1;++i) {
    if(a[i]==point) {
      now++;
    }
    else {
      if(now==0) A++;
      if(now==1) B++;
      if(now==2) C++;
    }
  }
  for(ll i=1;i<=N+1;++i) {
    cout<<(comb(N+1, i)-comb(A+C, i-1)+mod)%mod<<endl;
  }
}



Measured memory_bytes: 9324
//By Don4ick 
//#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;

#define forn(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define y1 qewr1234

const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};

const int N = 12;

using namespace std;

int n, m;
string s[N];
bool used[N], was[N];

void check(vector < pair < int, int > > v) 
{
	for (int i = 0; i < (int)v.size(); i++)
	{
		if (v[i].first == v[i].second)
		{
			swap(v[i], v[(int)v.size() - 1]);
			break;
		}
	}
	vector < string > a;	
	for (int i = 0; i < (int)v.size(); i++)
	{
		a.pb(s[v[i].first]);
	}
	for (int i = (int)v.size() - 1; i >= 0; i--)
	{	
		if (v[i].first != v[i].second)
			a.pb(s[v[i].second]);
	}
	bool found = false;
	vector < string > b;
	for (int i = 0; i < m; i++)
	{
		string cur;
		for (int j = 0; j < n; j++)
			cur += a[j][i];
		b.pb(cur);		
	}
	for (int i = 0; i < m; i++)
	{
		if (was[i])
			continue;
		reverse(all(b[i]));
		for (int j = i + 1; j < m; j++)
		{
			if (!was[j] && b[i] == b[j])
			{
				was[i] = was[j] = true;
				break;
			}
		}		
		reverse(all(b[i]));
		if (!was[i])
		{	
			if ((m & 1) && !found)
			{
				string t = b[i];
				reverse(all(t));
				if (b[i] == t)
				{
					found = true;
					was[i] = true;
				}
			}
		}
		if (!was[i])
		{
			return;
		}
	}
	cout << "YES" << endl;
	exit(0);
}

void rec(int id, bool found, vector < pair < int, int > > & v)
{
	if (id == n)
	{
		check(v);
		return;		
	}
	if (used[id])
	{
		rec(id + 1, found, v);	
		return;
	}
	if ((n & 1) && !found)
	{
		used[id] = true;
		v.pb({id, id});
		rec(id + 1, true, v);
		v.pop_back();
		used[id] = false;
	}
	for (int i = id + 1; i <= n; i++)
	{
		if (!used[i])
		{
			used[id] = used[i] = true;
			v.pb({id, i});
			rec(id + 1, found, v);
			used[id] = used[i] = false;
			v.pop_back();
		}
	}
	return;
}	 

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

	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

	//~read
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		cin >> s[i];	
	//~solve
	vector < pair < int, int > > v;
	rec(0, false, v);
	cout << "NO" << endl;

	return 0;
}



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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  int64_t res = 0;
  for (int i = 0; i < N; i++) {
    res += INT64_C(1) * (i + 1) * (i + 2) / 2;
  }
  for (int i = 0; i < N - 1; i++) {
    int u, v;
    cin >> u >> v;
    if (u > v) swap(u, v);
    res -= INT64_C(1) * u * (N - v + 1);
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 3576
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
public class Main {
	public static void main(final String[] args){
    
    Scanner sc = new Scanner(System.in);
    List<Integer> list1 = new ArrayList<>();
    List<Integer> list2 = new ArrayList<>();
    int n = sc.nextInt();
    int m = sc.nextInt();

    int x = sc.nextInt();
    int y = sc.nextInt();

    int max=-100;
    int min=100;


    for(int i = 0; i < n; i++){
        list1.add(sc.nextInt());
    }

    for(int i = 0; i < n ; i++){
        if(list1.get(i) >= max){
            max = list1.get(i);
        }else{}
    }

    for(int i = 0; i < m; i++){
        list2.add(sc.nextInt());
    }

    for(int i = 0; i < m; i++){
        if(list2.get(i) <= min){
            min = list2.get(i);
        }else{}
    }
    if(max >= x && max < min && max < y){
        System.out.println("No War");
    }else if(min < y && max < min && x < min){
        System.out.println("No War");
    }else{
        System.out.println("War");
    }




    
    
    
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
//using
using intl = long long;
using itnl = long long;//typo用
using uintl = unsigned long long;
using itn = int;//typo用
using ld = long double;
using namespace std;

//関数マクロ
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a) - 1; i >= (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define debug(x) cout << #x << ":" << x << endl

//定数マクロ
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>

//定数
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);

//テンプレート関数
template<class T> inline bool chmin(T& a, T b) { if (a > b) {a = b; return true;} return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) {a = b; return true;} return false; }
//intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); } //c++17からある
//intl lcm(intl a,intl b){ return a / gcd(a, b) * b; } //c++17からある

//自作テンプレート関数
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}//Yes,Noの出力を楽にするよう
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}//上の関数のYes,Noを任意の文字列でできるようにしたもの
intl kai(intl k){ intl a = 1; for(int i = 2; i <= k; i++){ a *= i; } return a; }//k!を求める関数,O(N)
intl digit10(intl a){ intl b = 0; do{ a /= 10; b++; }while(a); return b; }//aを10進数で表したときの桁数を求める関数,桁数回の演算だからだいたいO(logN)くらい?



signed main(){
    cout << fixed << setprecision(10);
    intl n;
    cin >> n;
    for(intl i = 0;;i += 1000){
        if(i >= n){
            cout << i - n << endl;
            break;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>
#include<queue>
#include<algorithm>
using namespace std;
char str[60][60];
int t[60][60];
int on[60][60];
int off[60][60];
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int v[60][60];
int last[60][60];
int row[1100];
int col[1100];
int n,m;
int time;
long long ret;
int dfs(int a,int b,int c,int d){
	v[a][b]=d;
	if(a==row[c]&&b==col[c]){
		if(!~last[a][b])ret+=on[a][b];
		else ret+=min(off[a][b]+on[a][b],t[a][b]*(d+time-last[a][b]));
		last[a][b]=time+d;
		return 1;
	}
	for(int i=0;i<4;i++){
		if(a+dx[i]<0||b+dy[i]<0||a+dx[i]>=n||b+dy[i]>=m)continue;
		if(str[a+dx[i]][b+dy[i]]=='#')continue;
		if(~v[a+dx[i]][b+dy[i]])continue;
		int res=dfs(a+dx[i],b+dy[i],c,d+1);
		if(res){
			if(d){
				if(!~last[a][b])ret+=on[a][b];
				else ret+=min(off[a][b]+on[a][b],t[a][b]*(d+time-last[a][b]));
				last[a][b]=time+d;
			}
			return 1;
		}
	}
	return 0;
}
int main(){
	int a,b,c;scanf("%d%d%d",&a,&b,&c);
	n=a;
	m=b;
	for(int i=0;i<a;i++){
		scanf("%s",str[i]);
	}
	for(int i=0;i<a;i++)for(int j=0;j<b;j++)scanf("%d",&t[i][j]);
	for(int i=0;i<a;i++)for(int j=0;j<b;j++)scanf("%d",&on[i][j]);
	for(int i=0;i<a;i++)for(int j=0;j<b;j++)scanf("%d",&off[i][j]);
	ret=0;
	for(int i=0;i<c;i++){
		scanf("%d%d",row+i,col+i);
	}
	for(int i=0;i<a;i++)for(int j=0;j<b;j++)last[i][j]=-1;
	last[row[0]][col[0]]=0;
	time=0;
	ret+=on[row[0]][col[0]];
	for(int i=1;i<c;i++){
		for(int j=0;j<a;j++)for(int k=0;k<b;k++)v[j][k]=-1;
		dfs(row[i-1],col[i-1],i,0);
		time+=v[row[i]][col[i]];
	}
	for(int i=0;i<a;i++)for(int j=0;j<b;j++)if(~last[i][j])ret+=off[i][j];
	printf("%lld\n",ret);
}

Measured memory_bytes: 1204
using System;
using System.Linq;

class prog{
  static void Main(){
    int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
    var l = Console.ReadLine().Split().Select(int.Parse).OrderByDescending(x => x).ToArray();
    int ans = 0;
    for(int i = 0; i < input[1]; i++){
      ans += l[i];
    }
    Console.WriteLine(ans);
  }
}

Measured memory_bytes: 13396
import math
from collections import defaultdict
import sys
input = sys.stdin.readline
pc = True
n = int(input())
a = list(map(int,input().split()))
g = math.gcd(a[0],a[1])
for i in range(2,n):
    g = math.gcd(g,a[i])
M = max(a)
class Sieve_of_Eratosthenes:
    def __init__(self, N):
        self.sieve = [-1] * (N+1)

        for i in range(2,N+1):
            if self.sieve[i] == -1:
                for j in range(1,1+N//i):
                    self.sieve[i*j] = i

    def isprime(self, num):
        if num <= 1:
            return False
        else:
            return self.sieve[num] == num

    def factorization(self, num):
        ret = set([])
        while num != 1:
            div = self.sieve[num]
            ret.add(div)
            num //= div
        return ret

sofe = Sieve_of_Eratosthenes(M)
ddic = defaultdict()
judge = set([])

for i in a:
    if not pc:
        break
    asf = sofe.factorization(i)
    
    if judge & asf != set():
        pc = False
    judge |= asf
if pc:
    print("pairwise coprime")
elif g == 1:
    print("setwise coprime")
else:
    print("not coprime")


Measured memory_bytes: 127712
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <climits>
using namespace std;

int main() {
    string s;
    cin >> s;
    string y=s.substr(0,4);
    string m=s.substr(5,2);
    string d=s.substr(8,2);
    int year=stoi(y),month=stoi(m),day=stoi(d);
    if(year<=2018){
        cout << "Heisei";
        return 0;
    }
    if(year<=2019 && month<=4 && day<=30){
        cout << "Heisei";
        return 0;
    }
    cout << "TBD";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

const ll MOD = 1e9+7;
const int MAX = 100050;
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;
}

ll n, k;
vl a;

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0);
	//freopen("in.txt", "r", stdin);
	COMinit();
	cin >> n >> k;
	a.resize(n+1);
	a[0] = -1e9-50;
	rep(i,1,n+1) {
		cin >> a[i];
	}
	sort(all(a));
	ll ret = 0;
	rep(i,k,n+1) {
		ret += (a[i] * COM(i-1,k-1));
		ret %= MOD;
		while(ret < 0) {
			ret += MOD;
		}
	}
	rep(i,1,n-k+2) {
		ret -= (a[i] * COM(n-i,k-1));
		ret %= MOD;
		while(ret < 0) {
			ret += MOD;
		}
	}
	cout << ret << '\n';
	return 0;
}

Measured memory_bytes: 3328
import math
ans = 0

K = int(input())

for i in range(1, K + 1):
    for j in range(1, K + 1):
        b = math.gcd(i, j)
        for k in range(1, K + 1):
            gcd = math.gcd(b, k)
            ans = ans + gcd

print(ans)

Measured memory_bytes: 9120
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

long long N, M, L[1 << 18], R[1 << 18], D[1 << 18];
long long dist[1 << 18];
vector<pair<int, long long>> X[1 << 18];

int main() {
	cin >> N >> M;
	for (int i = 1; i <= M; i++) {
		cin >> L[i] >> R[i] >> D[i];
		X[L[i]].push_back(make_pair(R[i], D[i]));
		X[R[i]].push_back(make_pair(L[i], -D[i]));
	}
	for (int i = 1; i <= N; i++) dist[i] = (1LL << 60);
	for (int i = 1; i <= N; i++) {
		if (dist[i] != (1LL << 60)) continue;
		queue<int> Q; Q.push(i); dist[i] = 0;
		while (!Q.empty()) {
			int pos = Q.front(); Q.pop();
			for (pair<int, long long> j : X[pos]) {
				long long nex = dist[pos] + j.second;
				if (dist[j.first] == (1LL << 60)) {
					dist[j.first] = nex;
					Q.push(j.first);
				}
				else if (dist[j.first] > nex) {
					cout << "No" << endl;
					return 0;
				}
			}
		}
	}
	for (int i = 1; i <= M; i++) {
		if (dist[R[i]] - dist[L[i]] != D[i]) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 25088
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, [ $t:tt ]) => {{
    let len = read_value!($iter, usize);
    (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  }};

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    n: usize,
    k: usize,
    s: i64,
  }
  let default = if s == 1 {
    2
  } else {
    s - 1
  };
  for _ in 0 .. k {
    puts!("{} ", s);
  }
  for _ in 0 .. n - k {
    puts!("{} ", default);
  }
  puts!("\n");
}


Measured memory_bytes: 5372
#include <bits/stdc++.h>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
const ll INF =999999999;

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}

//素数判定
ll isprime(ll n){
  bool prime=true;
  for(int i=2;i<n;i++){
    if(n%i==0){
      prime=false; break;
    }
  }
if(prime){cout<<n<<" is prime"<<endl;
         }else{cout<<n<<" is not prime"<<endl;}

}
//階乗　20くらいが限界
ll factorial(ll n){
  ll a=1;ll b=n;
  for(int i=0;i<n;i++){
    a*=b;
    b--;
  }
  return a;
}

//組み合わせ　nCr
ll comb(ll a,ll b){
  ll c;
  c=factorial(a)/(factorial(a-b)*factorial(b));
  return c; 
}




//10億7。　　　100000007
//2*2行列 H*W
//vector<vector<int>> vec(H,vector<int>(W));
//for(int i=0;i<H;i++){
//for(int j=0;j<W;j++){
//cin>>vec[i][j];
//  }
//}

//文字列→数列
//string S;int A=atoi(S.c_str());
//数列→文字列
//int A;string S=to_string(A);
//数字判定　isdigit(a)
//pair宣言　pair<int,int> p(5,7);
//ソート　sort(vec.begin(),vec.end());



int main(){
cout<<fixed<<setprecision(10);

  int N;cin>>N;
  if(N<1200){
cout<<"ABC"<<endl;
  }else if(1200<=N&&N<2800){
    cout<<"ARC"<<endl;
  }else {cout<<"AGC"<<endl;
        }
  
}


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

int main(){

        ll n,m,x;

        cin >> n >> m >> x;

        vector<ll> a(n);
        for(int a_i = 0; a_i <n; a_i++){
           cin >> a[a_i];
        }

        vector<ll> b(m);
        for(int b_i =0; b_i <m; b_i++){
           cin >> b[b_i];
        }

        ll sum=0,count=0,temp=0,i=0,j=0;

        while(i<n && sum+a[i]<=x){
            sum+=a[i];
            i++;
        }
        count=i;

        while(j<m && i>=0){
            sum+=b[j];
            j++;
            while(sum>x && i>0){
                i--;
                sum-=a[i];
            }
            if(sum<=x && i+j>count)
                count=i+j;
        }
        cout<<count<<endl;


}


Measured memory_bytes: 6420
/// Kazuki Hoshino
/// Lost July

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple



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

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

int a, b;
cin >> a >> b;

if(a+b==15){
    cout << '+' << endl;
}
else if(a*b==15){
    cout << '*' << endl;
}
else cout << "x" << endl;




return 0;}


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

int main() {
  int64_t n, k;
  cin >> n >> k;
  
  int64_t x;
  x = n % k;
  if (x > abs(x - k)) {
    cout << abs(x - k) << endl;
  }
  else {
    cout << x << endl;
  }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i, n) for (int i=0; i < (n); i++)
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int NIL = -1;
const int MAX = 10000;
const int MOD = 1000000007;
const double pi = 3.141592653589;

int main() {
    int n, m;
    cin >> n >> m;
    dsu d(n);
    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        d.merge(a, b);
    };
    set<int> renketu;
    rep(i, n){
        renketu.insert(d.leader(i));
    };
    long unsigned int ans = 0;
    ans = renketu.size() - 1;
    cout << ans << endl;
}

Measured memory_bytes: 7732
#include<iostream>
using namespace std;
int main(){
	int yami = 100000;
	int n;
	cin >> n;
	for(int i = 0;i < n; ++i){
		yami *= 1.05;
		if(yami % 1000)
			yami += 1000 - yami % 1000;
	}
	cout << yami << '\n';
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string a;
    cin >> a;
    int n = a.length();
    for(int i = 0; i < n; ++i){
        if(a[i] =='?')a[i] = 'D';
    }
    cout << a << '\n';
}


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

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i * 4 <= n; i++) {
    int j = n - 4 * i;
    if (j % 7 == 0) {
      puts("Yes");
      return 0;
    }
  }
  puts("No");
  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(input()) for i in range(N)]
lmax = [0]
rmax = [0]
for i in range(N-1):
  lmax.append(max(lmax[i],A[i]))
  rmax.append(max(rmax[i],A[N-1-i]))
 
rmax = rmax[::-1]

for i in range(N):
  print (max(lmax[i], rmax[i]))

Measured memory_bytes: 15732
#include<stdio.h>

int search( int A[] , int n , int key ){
  int i = 0;
  A[n] = key;
  while( A[i] != key ){
    i++;
  }
  return i != n;
}

int main(void){
  int i,n,A[10000],q,key,sum=0;
  scanf("%d",&n);
  for( i = 0 ; i < n ; i++ ){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for (i = 0 ; i < q ; i++){
    scanf("%d",&key);
    if ( search(A,n,key) ){
      sum++;
    }
  }
    printf("%d\n",sum);
  return 0;
}

Measured memory_bytes: 640
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
#include <float.h>
using namespace std;
// repマクロの定義
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// allマクロの定義
#define all(v) v.begin(), v.end()
typedef unsigned long long ll;

// 最大公約数求める関数
int my_gcd(int n , int m){
  if(n < m){
    int tmp = n;
    n = m;
    m = tmp;
  }
  int l  = n % m;
  while(l != 0){
    n = m;
    m = l;
    l = n % m;
}
return m;
}

//char⇒int関数
 int ctoi(char c) {
 	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}



int main(){
  string S;
  cin >> S;
  int N = S.size();
  vector<char> A(50),B(50);
  rep(i,N/2){
    A[i] = S[i];
    B[i] = S[i+(N/2)+1];
  }
  bool ans = true;
  rep(i,N/2){
    if(S[i] != S[N - i -1]){
      ans = false;
    }
  }
  rep(i,N/2){
    if(A[i] == S[N/2 - i - 1] && B[i] == S[N - i - 1]){
    }
    else ans = false;
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  }


Measured memory_bytes: 256