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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string S=in<string>();
	vector<int> flag(26,0);
	for(int i=0;i<4;i++){
		int v = S[i]-'A';
		flag[v]++;
	}
	sort(ALL(flag));
	
	if(flag[25]==2 && flag[24]==2) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
/*
 * Author       : YangDavid
 * Created Time : 2020年01月11日 星期六 19时34分06秒
 */

#include<bits/stdc++.h>
#define rep(i, n) for(int i = 1; i <= n; ++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int n, t[2333];
string s[2333];

int main() {
	scanf("%d", &n);
	rep(i, n) {
		cin >> s[i] >> t[i];
	}
	string x;
	cin >> x;
	rep(i, n) if(x == s[i]) {
		ll sum = 0;
		for(int j = i + 1; j <= n; ++j)
			sum += t[j];
		printf("%lld\n", sum);
		return 0;
	}

    return 0;
}


Measured memory_bytes: 256
while True:
    try:
        a,o,b=input().split()
        a=int(a)
        b=int(b)
    except EOFError:
        break
    if o == "+":
        print(a+b)
    elif o == "-":
        print(a-b)
    elif o == "*":
        print(a*b)
    elif o == "/":
        print(a//b)
    else:
        break


Measured memory_bytes: 5600
fun main(arr:Array<String>) {
    val n = readLine()!!.toInt()
    val num = readLine()!!.split(" ").map { it.toInt() }.toMutableList()
    var ans = 0
    for(i in (0 until n-1)) {
        if (num[i] == i + 1) {
            swap(i, i+1, num)
            ans++
        }
    }
    if(num.last() == num.lastIndex + 1) {
        ans++
        swap(num.lastIndex-1, num.lastIndex, num)
    }
    println(ans)
}

fun swap(idx1:Int, idx2:Int, num:MutableList<Int>) {
    val tmp = num[idx1]
    num[idx1] = num[idx2]
    num[idx2] = tmp
}


Measured memory_bytes: 52052
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);

/// easy access -------------
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
typedef pair<int,int> pi;
///-------------------------

int main()
{
    Phuong_; /// <3333
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    for(int &x:a) cin >> x;
    sort(a.begin(), a.end());
    int s=0;
    for(int i=0; i<k; ++i) s+=a[i];
    cout << s;
    return 0;
}


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

public class Main {
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			String in = br.readLine();
			String chr[] = in.split(" ");
			int a = Integer.parseInt(chr[0]);
			int b = Integer.parseInt(chr[1]);
			int c = Integer.parseInt(chr[2]);
			System.out.println(a+b+c-(Math.max(a, Math.max(b, c))));

		}
	}
}


Measured memory_bytes: 25400
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define int ll
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int a,b; cin>>a>>b;
	cout<<(a*3+b)/2<<"\n";
	return 0;
}















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

int main(){
    int n;
    int a[100001] = {};

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

    int ans = a[0];
    for(int i = 1;i < n;i++){
        ans = __gcd(ans, a[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <stdlib.h>
#include <string>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
int nx[2]={1,0};
int ny[2]={0,1};

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}

int main (){
    int n,m;
    cin >> n >> m;
    cout << n*(n-1)/2+ m*(m-1)/2<< endl;
    return 0;
}

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

l = [[] for i in range(n)]
for pi in ab:
    l[pi[0]-1].append(pi[1]-1)
    l[pi[1]-1].append(pi[0]-1)

ans=[0]*n

from collections import deque

def bfs(u):
    queue = deque([u])
    d = [None] * n # uからの距離の初期化
    d[u] = 0 # 自分との距離は0
    while queue:
        v = queue.popleft()
        for i in l[v]:
            if d[i] is None:
                ans[i] = v
                d[i] = d[v] + 1
                queue.append(i)

    for i in range(1,n):
        print(ans[i]+1)
    # return d
print('Yes')
d = bfs(0)


Measured memory_bytes: 70772
import re

S = input()

reg = ['^keyence.*', '^k.*eyence$', '^ke.*yence$', '^key.*ence$', '^keye.*nce$', '^keyen.*ce$', '^keyenc.*e$', '.*keyence$']

flg = False
for r in reg:
  if re.search(r, S):
    flg = True

if flg:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3188
n = int(input())
xyz = []
for i in range(n):
    xyz.append(list(map(int,input().split())))

for cx in range(101):
    for cy in range(101):
        mh = 10000000000
        h = []
        for i in range(n):
            x,y,z = xyz[i][0],xyz[i][1],xyz[i][2]
            if z == 0:
                mh = min(mh,abs(x-cx)+abs(y-cy))
            else:
                if len(h) == 0:
                    h.append(z+abs(x-cx)+abs(y-cy))
                else:
                    if h[0] != z+abs(x-cx)+abs(y-cy):
                        h = []
                        break
                    elif h[0]>mh:
                        h = []
                        break
            if len(h)>0 and h[0]>mh:
                h = []
                break
        if len(h) > 0:
            ans = str(cx)+" "+str(cy)+" "+str(h[0])
print(ans)


Measured memory_bytes: 44524
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
const int MAXN = 1e5 + 5;

int n;
ll a[MAXN];

bool ok(ll r,int i)
{
	if((r>>i)>1) return 0;
	if((r>>i)<1) return 1;
	for(int j=0; j<i; ++j)
		if((r>>j)&1ll)
			return 0;
	return 1;
}

ll b[MAXN];

const ll base = 1e17;
struct Data
{
	ll a,b;
	Data(){ a=b=0;}
	inline void add(ll x)
	{
		b += x;
		if(b>=base)
			b-=base,
			++a;
	}
	inline void print(void)
	{
		if(a) printf("%lld%017lld",a,b);
		else printf("%lld",b);
	}
};

int main(void)
{
	scanf("%d",&n);
	for(int i=0; i<=n; ++i)
		scanf("%lld",&a[i]);
	
	for(int i=n; i>=0; --i)
		b[i] = b[i+1] + a[i];
	
	Data ans;
	ll now = 1;
	for(int i=0; i<=n; ++i)
	{
		if(now<a[i]){ printf("-1"); return 0;}
		now = min(now, b[i]);
		ans.add(now);
		
		now = (now-a[i])*2;
	}
	
	ans.print();
	return 0;
}

Measured memory_bytes: 5280
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
int n;
using namespace std;
const int maxn=10000;
int a[maxn];
int main(){
	std::ios::sync_with_stdio(false);
	memset(a,0,sizeof(a));
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		cout<<a[i];
		if(i==n-1){
			cout<<"\n";
		}
		else{
			cout<<" ";
		}
	}
	
	for(int i=1;i<n;i++){
		int key=a[i];
		int j=i-1;
		while(j>=0&&a[j]>key){
			a[j+1]=a[j];
			j--;
		}
		
		a[j+1]=key;
		for(int i=0;i<n;i++){
			cout<<a[i];
			if(i==n-1){
				
				cout<<"\n";
		}
			else{
				cout<<" ";
		}
			
		}
	
	}
	return 0;
}

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

int main(int argc, char const *argv[]) {
  int H, W;
  cin >> H >> W;

  vector<vector<int>> c(10, vector<int>(10));
  vector<vector<int>> dp(10, vector<int>(10));
  vector<vector<int>> A(H + 1, vector<int>(W + 1));

  vector<int> count(10, 0);
  vector<int> cost(10, 0);

  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> c[i][j];
    }
  }

  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      cin >> A[i][j];
      if (A[i][j] != -1) {
        count[A[i][j]]++;
      }
    }
  }

  if (count[1] == H * W) {
    cout << 0 << "\n";
    return 0;
  }

  //ワーシャルフロイド
  for (int k = 0; k < 10; k++) {
    for (int i = 0; i < 10; i++) {
      for (int j = 0; j < 10; j++) {
        c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
      }
    }
  }

  int ans = 0;
  for (int i = 0; i < 10; i++) {
    ans += count[i] * c[i][1];
  }

  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 384
#include <string>
#include <vector>
#include <map>
#include <deque>
#include <iostream>
#include <queue>
#include <math.h>
#include <algorithm>
#include <fstream>

using namespace std;
typedef long long ll;


int main(void) {
	int n,d;
	cin >> n >> d;
	int a = (d * 2) + 1;
	cout << (n + (a - 1)) / a;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    static Map<Integer,List<Integer>> map = new HashMap();
    static int dp[] = new int[100001];
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int edges = sc.nextInt();
        int dp[] = new int[n+1];
        int ans = 0;
        for(int i=0;i<edges;i++){
            int a = sc.nextInt();
            int b = sc.nextInt();
            if(!map.containsKey(a))
                map.put(a,new ArrayList());
            map.get(a).add(b);
        }
        for(int i=1;i<=n;i++){
            ans = Math.max(ans,dfs(i));
        }
        System.out.println(ans);
    }
    static int dfs(int cur){
        int tmp = 0;
        if(dp[cur]!=0){
            return dp[cur];
        }
        if(!map.containsKey(cur))
            return 0;
        for(int next : map.get(cur))
            tmp = Math.max(tmp,dfs(next)+1);
        dp[cur] = tmp;
        return tmp;
    }
}

Measured memory_bytes: 82460
#include <bits/stdc++.h>
using namespace std;
int main()
{
    char c[2][3];
    for(int i = 0;i < 2;i++)
    {
        for(int j = 0;j < 3;j++)
        {
            cin >> c[i][j];
        }
    }
    bool flag = true;
    if(c[0][0] != c[1][2])
    {
        flag = false;
    }
    else if(c[0][1] != c[1][1])
    {
        flag = false;
    }
    else if(c[0][2] != c[1][0])
    {
        flag = false;
    }
    if(flag)
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }
    
    return 0;
}

Measured memory_bytes: 256
h, n = gets.split(" ").map(&:to_i)
magics = []
amax = 0
n.times do
  a, b = gets.split(" ").map(&:to_i)
  magics.push([a, b])
  amax = a if amax < a
end

hh = h + amax
dp = Array.new(hh + 1, 1.0 / 0)
dp[0] = 0

(1..hh).step do |i|
  magics.each do |m|
    dp[i] = dp[i - m[0]] + m[1] if i - m[0] >= 0 && dp[i] > dp[i - m[0]] + m[1]
  end
end

puts dp[h..-1].min

Measured memory_bytes: 2172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;

struct edge{
    int to,weight;
    edge(int to,int weight):to(to),weight(weight){}
};
using Graph = vector<vector<int>> ;
using GraphEdge = vector<vector<int>> ;

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}
int main(){
    string N;cin >> N;
    ll count = 0;
    int len = N.length();
    rep(i,len){
        int num = N[i] - '0';
        count += num;
    }
    if(count % 9==0)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3736
/**
 * Queue
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_B&lang=ja
 */

#include<iostream>
#include<vector>
#include<algorithm>
#include <queue>
using namespace std;

struct Process {
  string name;
  int time;
};

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

  // プロセスの格納
  queue <Process>queues;
  for (int i = 0; i < N; i++) {
    Process p = Process();
    cin >> p.name >> p.time;
    queues.push(p);
  }

  int time = 0;
  // プロセスが残っている間は続ける
  while (queues.size() > 0) {
    // キューからプロセスをひとつ取り出す
    Process p = queues.front();
    queues.pop();

    if (p.time > q) {
      // 100msをプロセスで消費させて、キューの末尾で順番待ちさせる
      time += q;
      p.time -= q;
      queues.push(p);
    } else {
      time += p.time;
      cout << p.name << ' ' << time << endl;
    }
  }

  return 0;
}




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

#define rep(i, n) for (int i = 0; i < (n); ++i)

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  int num1 = N / K;
  int num2 = 0;
  if (K % 2 == 0)
  {
    num2 += N / K;
    if (N % K >= K / 2)
    {
      num2++;
    }
  }

  long long sum = (long long)num1 * num1 * num1 + (long long)num2 * num2 * num2;

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(long long N, long long K, std::vector<long long> H){
  sort(H.rbegin(), H.rend());
  ll sum = 0;
  for(ll i=K; i<N; i++)
    sum+=H[i];
  std::cout << sum << std::endl;
}

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



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main (){
string s;
int temp=0,maxx=0;
cin>>s;
for(int i=0;i<s.length();i++)
        if(s[i]=='R')temp++;
        else maxx=max(maxx,temp),temp=0;
if(temp)maxx=max(maxx,temp);
cout<<maxx<<endl;
return 0;
}


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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int N;
  cin >> N;
  map<pair<int, int>, int> count;
  int a;
  REPI(i, 1, N + 1) {
    cin >> a;
    pair<int, int> key = make_pair(min(i, a), max(i, a));
    if (count.find(key) == count.end()) {
      count.insert(make_pair(key, 1));
    } else {
      ++count.at(key);
    }
  }

  int ans = 0;
  for (auto const &it : count) {
    if (it.second == 2) {
      ++ans;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6528
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    edges = 0
    for i in range(N-1):
        v, w = LI()
        if v > w:
            v, w = w, v
        edges += v * (N - w + 1)
    v = 0
    for i in range(N):
        v += (N-i+1) * (N-i) // 2
    print(v - edges)

main()



Measured memory_bytes: 84520
#import <stdio.h>
#define MAX(a,b) ((a)>(b)?(a):(b))
int main() {
    int n;
    char S[200];
    scanf("%d %s", &n, S);
    int x=0;
    int max=0;
    for (int a=0;a<n;a++){
        if (S[a]=='I') {
            x++;
            max = MAX(max,x);
            continue;
        }
        x--;
    }
    printf("%d", max);
}


Measured memory_bytes: 2164
#include <iostream>
#include <vector>
#include <algorithm>

typedef long long ll;

template <typename Head> void print(Head&& head) { std::cout << head << std::endl; }
template <typename Head, typename... Tail> void print(Head&& head, Tail&&... tail)
{
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...); // or print(tail...);
}

int main(int argc, char* argv[])
{
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  ll N;
  std::cin >> N;
  std::vector< std::pair< ll, std::pair< ll, ll> > > vp(N);
  for (ll i = 0; i < N; i++) {
    ll a, b;
    std::cin >> a >> b;
    vp[i].first = a + b;
    vp[i].second = std::make_pair(a, b);
  }

  ll ans = 0;
  std::sort(vp.begin(), vp.end(), std::greater<>());
  for (ll i = 0; i < N; i++) {
    ll a = (vp[i].second).first;
    ll b = (vp[i].second).second;
    if (i % 2 == 0) {
      ans += a;
    } else {
      ans -= b;
    }
  }

  print(ans);
  return 0;
}


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

using namespace std;

const int N = 100 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

int n;
int col[N];
vector< pair<int, int> > g[N];

bool read() {
    if (!(cin >> n))
        return false;

    for (int i = 0; i < n - 1; ++i) {
        int u, v, w;
        cin >> u >> v >> w;
        g[u - 1].emplace_back(v - 1, w % 2);
        g[v - 1].emplace_back(u - 1, w % 2);
    }

    return true;
}

void dfs(int v, int pr, int h) {
    col[v] = h;

    for (auto to : g[v])
        if (to.first != pr)
            dfs(to.first, v, (h ^ to.second));
}

void solve() {
    dfs(0, -1, 0);

    for (int i = 0; i < n; ++i)
        cout << col[i] << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long h,w;
  cin >> h >> w;
  //vector<vector<int>> data(h, vector<int>(w));
  
  /*for(int i=0;i<h;i++){
   for(int j=0;j<w;j++){
    if(data.at(i).at(j))
   }
  }*/
  if(h==1||w==1)cout << 1 << endl;
  else {
  if(h*w%2==0)cout << h*w/2 << endl;
  else cout << (h*w+1)/2 << endl;
  }
  //cout <<  << endl;
}
  
  

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>
 
#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000
 
using namespace std;
 
int main(void) {
	char c[3][4];
 
	FOR(i, 1, 2) {
		cin >> c[i];
	}
 
	if (c[1][2] == c[2][0] && c[1][1] == c[2][1] && c[1][0] == c[2][2]) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
// Author: πα

#include <bits/stdc++.h>
using namespace std;
#define long int64_t

set<long> divisors(long x)
{
    set<long> s;
    for(long i = 1; i*i <= x; ++i)
        if(x % i == 0)
            s.insert(i), s.insert(x/i);
    s.erase(x);
    return s;
}

int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int n, d;
    cin >> n;
    vector<bool> v(n+1);
    for(int i = 1; i <= n; ++i)
        cin >> d, v[i] = d;
    for(int i = n; i; --i)
        for(auto it : divisors(i))
            v[it] = v[it] ^ v[i];
    vector<int> ans;
    for(int i = 1; i <= n; ++i)
        if(v[i])
            ans.push_back(i);
    cout << ans.size() << '\n';
    for(auto it : ans)
        cout << it << ' ';
    return 0;
}


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

using namespace std;

typedef long long int ll;

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

typedef pair<int,int> pair;

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

    if(m==0){
        cout << "0 0" << endl;
        return 0;
    }

    vector<int> p(m);
    vector<string> s(m);
    for(int i=0;i<m;i++){
        cin >> p[i] >> s[i];
    }

    int ans[2][n]={0}; //１：AC数、２：WA数

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

    for(int i=0;i<m;i++){
        if(s[i]=="AC"){
            ans[0][p[i]-1]=1;
            continue;
        }
        if(s[i]=="WA"){
            if(ans[0][p[i]-1]==0){
                ans[1][p[i]-1]++;
            }
        }
    }

    sort(p.begin(),p.end());
    vector<int> P;
    P.emplace_back(p[0]);
    for(int i=1;i<m;i++){
        int end=P.size(); 
        if(P[end-1]!=p[i]){
            P.emplace_back(p[i]);
        }
    }

    int x=0,y=0;

    for(auto v : P){
        if(ans[0][v-1]==0){
            ans[1][v-1]=0;
        }
        x+=ans[0][v-1];
        y+=ans[1][v-1];
    }

    printf("%d %d\n",x,y);

}

Measured memory_bytes: 7548
N,M=map(int,input().split())
G=[[False]*(N+1) for _ in range(N+1)]
for i in range(M):
    a,b=map(int,input().split())
    G[a][b]=True
    G[b][a]=True

visited=[False]*(N+1)

visited[1]=True
def dfs(start):
    global N
    global visited
    all_visited=True
    sum=0

    for p in range(1,N+1):
        if not visited[p]:
            all_visited=False

    if all_visited:
        return 1
    else:
        for next in range(1,N+1):#N小より全探索
            if not G[start][next]:
                continue
            if visited[next]:
                continue
            visited[next]=True
            sum+=dfs(next)
            visited[next]=False   #backtrack

        return sum

print(dfs(1))


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int dp[n][3];
  int a,b,c;
  for(int i=0;i<n;i++)
  {
    cin>>a>>b>>c;
    if(i==0)
    { dp[0][0]=a;
      dp[0][1]=b;
      dp[0][2]=c;
    }
    else
    {
      dp[i][0]=a+max(dp[i-1][1],dp[i-1][2]);
      dp[i][1]=b+max(dp[i-1][0],dp[i-1][2]);
      dp[i][2]=c+max(dp[i-1][0],dp[i-1][1]);
    }
  }
    int m=max(dp[n-1][1],dp[n-1][2]);
    m=max(m,dp[n-1][0]);
    cout<<m;
    return 0;
  }



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

using namespace std;

int main() {
    long long N = 0;
    cin >> N;
    for (long long i = pow(N,0.5); i>0 ; i--)
    {
        if (N%i==0)
        {
            //cout << i << endl;

            N = N/i;
            int ans = 0;
            while (true)
            {
                N /= 10;
                ans++;
                if (N==0)
                {
                    break;
                }
                
            }
            cout << ans  << endl;
            break;
            
            /* code */
        }
        //cout << i << endl;
        
    }
    


    return 0;
}

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

#define Rep(i,n)        for(int i = 0; i < (n); ++i)
#define Repd(i,n)       for(int i = (n)-1; i >= 0; --i)
#define For(i,a,b)      for(int i = (a); i <= (b); ++i)
#define Ford(i,a,b)     for(int i = (a); i >= (b); --i)
#define ALL(a)          (a).begin(), (a).end()
#define pb	push_back
#define NAME            "TEST"
#define FAST            ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define READ            freopen(NAME".INP","r",stdin);
#define WRITE           freopen(NAME".OUT","w",stdout);
#define gc 		getchar
#define pc		putchar
#define watch(x) 	cout << (#x) << " is " << (x) << '\n'

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef float fl;
typedef double db;
const int inf = 1e6;
const int Linf = 1e9;
const ll LLinf = (ll)1e18;
const int maxn = 1e6;


template<typename T = int> inline T read() {
	T val = 0, sign = 1; char ch;
	for (ch = getchar(); ch < '0' || ch > '9'; ch = getchar())
		if (ch == '-') sign = -1;
	for (; ch >= '0' && ch <= '9'; ch = getchar())
		val = val * 10 + ch - '0';
	return sign * val;
}
typedef vector<vector<ll>> Matrix;
typedef vector<ll> Array;
#define newmatrix(m,n,v) Matrix(m , Array(n , v))
#define nRow(a) (int(a.size()))
#define nCol(a) (int(a[0].size()))
int mod = 1e9 + 7;
Matrix operator * (const Matrix & a , const Matrix & b)
{
    Matrix result = newmatrix(nRow(a),nCol(b),0);
    Rep(i,nRow(a))
        Rep(j,nCol(b))
            Rep(k,nCol(a))
                result[i][j] = (result[i][j] + a[i][k] * (ll)b[k][j]) % mod;
    return result;
}
Matrix Matrandonvi(int n){
    Matrix result = newmatrix(n , n , 0);
    for(int i = 0 ; i < n; ++i){
        result[i][i] = 1;
    }
    return result;
}
Matrix Getmatrix(int n)
{
    Matrix result = newmatrix(n , n , 0);
    for(int i = 0 ; i < n ; ++i)
        for(int j = 0 ; j < n ; ++j)cin >> result[i][j];
    return result;
}
Matrix solve(int n , ll k)
{
    Matrix result = Matrandonvi(n);
    Matrix a = Getmatrix(n);
    while(k != 0)
    {
        if((k & 1))result = result * a;
        a = a * a;
        k /= 2;
    }
    return result;
}
void RES()
{
    ll n , k;
    cin >> n >> k;
    Matrix res = solve(n , k);
    int ans = 0;
    for(int i = 0 ; i < n ; ++i)
        for(int j = 0 ; j < n ; ++j)ans = (ans + res[i][j]) % mod;
    cout << ans;
}
int main()
{
    FAST;//READ;WRITE;
    RES();
}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

int main(void){
    int n,a;
    long long ans=0;
    scanf("%d%d",&n,&a);
    int x[n],max=a;
    for (int i=0; i<n; i++){
        scanf("%d",&x[i]);
        if (max<x[i]){
            max=x[i];
        }
    }
    int j,k,l;
    long long dp[n+2][n+2][2*n*max];
    for (j=0; j<=n; j++){
        for (k=0; k<=j; k++){
            for (l=0; l<=k*max; l++){
                if (j==0 && k==0 && l==0){
                    dp[j][k][l]=1;

                } else if (j>=1 && l<x[j-1]) {
                    dp[j][k][l]=dp[j-1][k][l];
                    
                    
                } else if (j>=1 && k>=1 && l>=x[j-1]){
                    dp[j][k][l]=dp[j-1][k][l]+dp[j-1][k-1][l-x[j-1]];
                    
                } else {
                    dp[j][k][l]=0;
                }
                if (j==n && k>=1 && l==k*a){
                    ans+=dp[j][k][l];
                }
            }
        }

    }
    printf("%lld\n",ans);
	return 0 ;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i != 0) {
            continue; 
        }
        long long ex = 0; // 指数
        // 割れるだけ割る
        while (N % i == 0) {
            ++ex;
            N /= i;
        }
        // 結果を push
        res.push_back({i, ex});
    }

    // 残った数はそのまま push
    if (N != 1) {
        res.push_back({N, 1});
    }

    return res;
}

int main() {
    long long N;
    cin >> N;
    vector<pair<long long, long long> > res = prime_factorize(N);
    cout << N << ":";
    for (pair<long long, long long> p : res) {
        for (int i = 0; i < p.second; ++i) {
            cout << " " << p.first;
        }
    }
    cout << endl;

    return 0;
}




Measured memory_bytes: 3116
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int main(void) {
    string s;
    int k;
    cin >> k >> s;
    if (s.length() <= k)
        cout << s;
    else {
        for (int i = 0; i < k; i++)
            cout << s[i];
        cout << "...";
    }
}

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

#define INF ((1<<30)-1)  //int32_t
#define MOD 1000000007
#define MOD2  

#define all(a)  (a).begin(),(a).end()

#define mkp make_pair
#define pb push_back

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;



int main(){
    bool flag=true;
    ll ans=0,sum=0;

    int q;
    cin >>q;

    vector<int> pnum(100001);
    vector<int> qans(100001);
    fill(all(qans),0);

    vector<bool> prime(100001);
    fill(all(prime),true);
    prime[0]=false;prime[1]=false;

    for (int i = 2; i <= 100000; i++){

        if(prime[i]){
            for (int j = i*2; j <= 100000; j+=i)prime[j]=false;
        }
    }

    int count=0;
    
    /*
    for (int i = 0; i <= 100000; i++)
    {
        if(prime[i]){
            count++;
        }
        pnum[i]=count;
    }*/
    
    count=0;
    for (int i = 1; i <= 100000; i+=2){
        int j = (i+1)/2;

        if(prime[i]&&prime[j]){
            count++;
        }
        qans[i]=count;
    }
    



    for (int i = 0; i < q; i++){
        int l,r;
        cin >>l>>r;

        int a = qans[r] - qans[max(l-2,1)];
        cout << a << '\n';

    }
    

    //cout <<fixed<<setprecision(16)<< << endl;
    //cout << ans << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;
#define SAY_YES cout<<"YES"<<endl;
#define SAY_Yes cout<<"Yes"<<endl;
#define SAY_NO cout<<"NO"<<endl;
#define SAY_No cout<<"No"<<endl;
#define IFYES(TRUE_OR_FALSE) if(TRUE_OR_FALSE){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;} 
#define IFYes(TRUE_OR_FALSE) if(TRUE_OR_FALSE){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;} 
#define IFyes(TRUE_OR_FALSE) if(TRUE_OR_FALSE){cout<<"yes"<<endl;}else{cout<<"no"<<endl;} 

const long long int mod=1000000007;
const long long int INF=99999999999999999;



long long int N,M,K,A[2000];
int main() {
	cout << fixed << setprecision(18);
	cin>>N;
    for(int i=0;i<N;i++){
        cin>>A[i];
        if(A[i]%2==0&&(A[i]%3!=0&&A[i]%5!=0)){
            cout<<"DENIED"<<endl;
            return 0;
        }
        
    }
    
     cout<<"APPROVED"<<endl;
} 


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

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<long long> L(N + 1);
	L[0] = 2;
	L[1] = 1;
	for (int i = 2; i <= N; ++i) {
		L[i] = L[i - 1] + L[i - 2];
	}
	cout << L[N] << endl;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


typedef long double D;
const D PI = acos(-1.0);
const D EPS = 1e-10;
class P { public:
  D x, y;
  P(D x=0, D y=0) : x(x), y(y) {}

  P& operator+=(const P& o) { x += o.x; y += o.y; return *this; }
  P& operator-=(const P& o) { x -= o.x; y -= o.y; return *this; }
  P& operator*=(const P& o) { return *this = {x*o.x - y*o.y, x*o.y + y*o.x}; }
  P& operator*=(const D& r) { x *= r; y *= r; return *this; }
  P& operator/=(const D& r) { x /= r; y /= r; return *this; }
  P operator-() const { return {-x, -y}; }

  D norm() const { return x*x + y*y; }
  D abs() const { return sqrt(norm()); }
  D arg() const { return atan2(y, x); }
  bool isZero() const { return std::abs(x) < EPS && std::abs(y) < EPS; }
  /** 象限 */
  int orth() const { return y >= 0 ? (x >= 0 ? 1 : 2) : (x < 0 ? 3 : 4); }
  bool operator < (const P& b) {
    return arg() < b.arg();
  }
  static P polar(const D& rho, const D& theta = 0) { return {rho * cos(theta), rho * sin(theta)}; }
};
std::ostream &operator<<(std::ostream &os, P const &p) { return os << "(" << p.x << ", " << p.y << ")"; }
P operator+(const P& p, const P& q) { return P(p) += q; }
P operator-(const P& p, const P& q) { return P(p) -= q; }
P operator*(const P& p, const P& q) { return P(p) *= q; }
P operator*(const P& p, const D& r) { return P(p) *= r; }
P operator/(const P& p, const D& r) { return P(p) /= r; }
P operator*(const D& r, const P& p) { return P(p) *= r; }
P operator/(const D& r, const P& p) { return P(p) /= r; }
D crs(P a, P b){ return a.x*b.y - a.y*b.x; }
D dot(P a, P b){ return a.x*b.x + a.y*b.y; }
int signum(D x) {return x > EPS ? +1 : x < -EPS ? -1 : 0;}


int main2() {
  int N; cin >> N;
  vector<P> p(N);
  REP(i, N) {
    int x, y; cin >> x >> y;
    p[i] = P(x, y);
  }
  sort(ALL(p));

  double ans = 0;
  REP(i, N) {
    P s;
    REP(k, N) {
      s += p[(i + k) % N];
      chmax(ans, (double)s.abs());
    }
  }
  printf("%.12f\n", ans);

  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int main(void){
  int a,n;
  char c='\0';
  scanf("%d",&a);
  getchar();
  while(true){
    scanf("%c",&c);
    getchar();
    if(c=='=')break;
    scanf("%d",&n);
    getchar();
    if(c=='+'){
      a+=n;
    }
    else if(c=='-'){
      a-=n;
    }
    else if(c=='*'){
      a*=n;
    }
    else if(c=='/'){
      a/=n;
    }
  }
  printf("%d\n",a);
  return 0;
}

Measured memory_bytes: 1028
/*----------------------|
/ Author : Ashraf Tasin |
/ Date   :   08.08.19   |
/----------------------*/

#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define all v.begin(),v.end()
#define flash ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define db double
#define endl "\n"
#define mnm pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>
#define show for(int i=0;i<v.size();i++) cout << v[i] << " ";
#define eps 1e-6
#define mx 100008
using namespace std;

int dx[]={-1,1,-1,0,1,-1,0,1};
int dy[]={0,0,-1,-1,-1,1,1,1};

/*Knight Moves

int dx[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int dy[] = { 1, 2, 2, 1, -1, -2, -2, -1 }; */

/*Normal Moves

int x[] = {0, 1, 0, -1};
int y[] = {-1, 0, 1, 0}; */


int main()
{
   // freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    flash

    int a,b;
    cin >> a >> b;
    cout << max(a-b,max(a+b,a*b)) << endl;

    return 0;
}


Measured memory_bytes: 256
import numpy as np
import sys

n = int(input())

_ = input().split()
a = np.array([int(k) for k in _])

_ = input().split()
b = np.array([int(k) for k in _])


diff = a - b
if diff.sum() < 0:
    print(-1)
    sys.exit()

count = 0
j = 0
pos = np.sort(diff[np.where(diff > 0)[0]])[::-1]
neg = np.sort(diff[np.where(diff < 0)[0]])

buf = pos[j]
i = 0

# print(pos, neg)
while i < len(neg):
    if abs(neg[i]) <= buf:
        buf += neg[i]
        i += 1
        count += 1   # neg
    else:
        d = 0
        while abs(neg[i]) > buf:
            d += 1
            buf += pos[j + d]
        j += d
        count += d
if count > 0:
    count += 1
print(count)


Measured memory_bytes: 29092
/*
ID: rchalam1
LANG: C++14
TASK:
*/
// For train.usaco.org, fill the template above.

// Competitive Coding Template

// GCC OPTIMIAZTION FLAGS
#ifdef ONLINE_JUDGE
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#include <bits/stdc++.h>

/*
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
*/
// All Includes for Competitive Coding Template

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

using vi = std::vector<int>;
using vll = std::vector<long long>;
using vull = std::vector<unsigned long long>;

#define FOR(i, a, b) for (auto i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (auto i = (a); i >= (b); --i)
#define R0F(i, a) ROF(i, a, 0)
#define ITR(a, x) for (auto& a: x)

#define FSRT(set) sort((set).begin(),(set).end())
#define RSRT(set) sort((set).rbegin(),(set).rend())
#define CSRT(set, function) sort((set).begin(),(set).end(), (function))
#define TRS(set) sort((set).begin(),(set).end(), greater<>())
#define REV(set) reverse((set).begin(),(set).end());

#define ALL(set) (set).begin(), (set).end()

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// For stdio, call setIO() or setIO("").
void setIO(std::ifstream &readFile, std::ofstream &writeFile, const std::string &name = "", bool stdIO = false)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	if(!name.empty() && !stdIO)
	{
		readFile.open(name + ".in");
		if(readFile.fail()) return;
		writeFile.open(name + ".out");
		std::cin.rdbuf(readFile.rdbuf());
		std::cout.rdbuf(writeFile.rdbuf());
	}
}

// To time program, create object Timer  to start timing, and call Timer.elapsed().
#include <chrono>

class Timer
{
	std::chrono::time_point<std::chrono::high_resolution_clock> m_beg;
public:
	Timer() : m_beg(std::chrono::high_resolution_clock::now())
	{}

	void reset()
	{ m_beg = std::chrono::high_resolution_clock::now(); }

	[[nodiscard]] long double elapsed() const
	{
		return std::chrono::duration_cast<std::chrono::duration<long double, std::ratio<1> >>(
				std::chrono::high_resolution_clock::now() - m_beg).count();
	}
};

// Defines datatype
using dt = int;
// Defines MAXN value
constexpr dt MAXN = 1e5 + 1;
// Defines Modulus
constexpr dt MOD = 1e9 + 7;
// Defines Floating Point Correction
constexpr long double EPS = 1e-9;

//*****
//START CODE BELOW
//*****

int main(int argc, char *argv[])
{
	static std::ifstream readFile;
	static std::ofstream writeFile;
	setIO(readFile, writeFile);
	int n, m, x;
	cin >> n >> m >> x;
	vector<bool> toll(n + 1, false);
	while(m--)
	{
		int a;
		cin >> a;
		toll[a] = true;
	}
	cout << min(count(toll.begin(), toll.begin() + x, true), count(toll.begin() + x, toll.end(), true)) << '\n';
}

Measured memory_bytes: 3596
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

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

		Set<Long> set = new HashSet<>();
		set.add(A);
		set.add(B);
		set.add(C);

		System.out.println(set.size());
	}
}


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

int main(){
    while(1){
        int a,b ;
        char op ;
        cin >> a >> op >> b ;
        if(op=='+') cout << a+b << endl ;
        else if(op=='-') cout << a-b << endl ;
        else if(op=='*') cout << a*b << endl ;
        else if(op=='/') cout << a/b << endl ;
        else break ;
    }
}


Measured memory_bytes: 3108
// by ul {{{
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(c) begin(c),end(c)
#define REP(i,n) for ( int i=0; i<(int)(n); i++ )
#define REP1(i,a,b) for ( int i=(int)(a); i<=(int)(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;

void RI() {}

template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}

template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }
// }}}
int n;
void input() {
    RI(n);
}

void solve() {
    int t = (double)n/1.08;
    if (int(t * 1.08) == n)
    {
        printf("%d\n", t);
    }
    else if (int((t + 1) * 1.08) == n) {
        printf("%d\n", t+1);
    } else {
            printf(":(\n");
    }
}

int main( int argc, char *argv[] ) {
    input();
    solve();
    return 0;
}


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

int n,m,x;
set<int> q={};

int main(){
    scanf("%d %d %d",&n,&m,&x);
    x=min(x,(m-n)/2+1);
    for(int i=0;i<x;i++){
        q.insert(m-i);
        q.insert(n+i);
    }
    for (auto x:q){
        printf("%d\n",x);
    }
}

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

typedef unsigned long long int LL;
#define REP(n) for(LL i = 0; i < (n); i++)
#define COUT(val) cout << (val) << endl
#define CIN(val) cin >> (val)
#define SORT(vec) sort(vec.begin(), vec.end())
#define SORT_GRE(vec) sort(vec.begin(), vec.end(), greater<LL>())

int main(){
    LL n, p;
    cin >> n >> p;
    LL powNum, keeper;
    if(n == 1){
        cout << p << endl;
        return 0;
    }
    if(n >= 60){
        cout << 1 << endl;
        return 0;
    }
    for(LL i = 1; i <= 1145141919810; i++){
        powNum = pow(i, n);
        if(powNum > p){
            powNum = pow(i-1, n);
            keeper = i - 1;
            break;
        } else if(powNum == p){
            cout << i << endl;
            return 0;
        }
    }
    while(1){
        if(p % powNum == 0){
            cout << keeper << endl;
            return 0;
        } else {
            keeper--;
            powNum = pow(keeper, n);
        }
    }
    cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int H, W; cin >> H >> W;
    vector<vector<char>> ans(H+2, vector<char>(W+2, '#'));
    for(int i = 1; i <= H; ++i){
        for(int j = 1; j <= W; ++j){
            cin >> ans[i][j];
        }
    }
    rep(i,H+2){
        rep(j,W+2) cout << ans[i][j];
        cout << endl;
    }
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(dead_code)]
use std::cmp;
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::{self, stdin, BufRead};
use std::str::FromStr;

fn read_one<T>() -> T
where
    T: FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    let stdin = stdin();
    let mut handle = stdin.lock();
    let mut buf = String::new();
    handle.read_line(&mut buf).unwrap();

    buf.trim().parse::<T>().unwrap()
}

macro_rules! read_tuple {
        ( $( $t:ty ), * ) => {
            {
                let stdin = stdin();
                let mut handle = stdin.lock();
                let mut buf = String::new();
                handle.read_line(&mut buf).unwrap();
                let mut v = buf.trim().split_whitespace()
                    .collect::<VecDeque<&str>>();
                (
                    $({
                        v.pop_front().unwrap().parse::<$t>().unwrap()
                    },)*
                )
            }
        }
    }

fn read_vec<T>() -> Vec<T>
where
    T: FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    let stdin = stdin();
    let mut handle = stdin.lock();
    let mut buf = String::new();
    handle.read_line(&mut buf).unwrap();

    buf.trim()
        .split_whitespace()
        .map(|s| s.parse::<T>().unwrap())
        .collect::<Vec<T>>()
}

fn get_gcd(a: i32, b: i32) -> i32 {
    if a < b {
        return get_gcd(b, a);
    } else if b == 0 {
        return a;
    } else {
        return get_gcd(b, a % b);
    }
}

fn main() -> io::Result<()> {
    let mut n = read_one::<i32>();
    let mut sum = 0;
    for i in 1..n + 1 {
        for j in 1..n + 1 {
            for k in 1..n + 1 {
                sum += get_gcd(i, get_gcd(j, k));
            }
        }
    }
    println!("{}", sum);
    return Ok(());
}


Measured memory_bytes: 2184
import sys
from time import time, sleep
from random import random
from bisect import bisect, bisect_left
def inpl(): return list(map(int, input().split()))
start = time()
D = int(input())
C = inpl()
S = [inpl() for _ in range(D)]
X = [0]*D
res = []
max_score = -10**9

score = 0
A = [[] for _ in range(26)]
for i in range(D):
    X[i] = i%26
    A[X[i]].append(i)
for i in range(26):
    s = -1
    for j in range(len(A[i])):
        a = A[i][j]
        n = a - s - 1
        score += S[a][i] - n*(n-1)*C[i]//2
        s = a
    n = D - 1 - s
    score -= n*(n-1)*C[i]//2
if score > max_score:
    max_score = score
    res = [x for x in X]
#print(max_score, file=sys.stderr)

from bisect import bisect
while (time() - start < 1.8):
    tmp = 0
    d = int(random() * D)
    x = X[d]
    y = int(random() * 26)
    if x == y:
        continue
    tmp += -S[d][x] + S[d][y]
    di = bisect_left(A[x], d)
    d0 = -1 if di == 0 else A[x][di-1]
    d2 = D - 1 if (di >= len(A[x]) - 1) else A[x][di+1]
    tmp += -(d2-d0)*(d2-d0-1)*C[x]//2 + (d-d0)*(d-d0-1)*C[x]//2 + (d2-d)*(d2-d-1)*C[x]//2

    d0i = bisect_left(A[y], d) - 1
    d0 = -1 if d0i == -1 else A[y][d0i]
    d2 = D - 1 if d0i == len(A[y]) - 1 else A[y][d0i+1]
    tmp += (d2-d0)*(d2-d0-1)*C[y]//2 - (d-d0)*(d-d0-1)*C[y]//2 - (d2-d)*(d2-d-1)*C[y]//2
    if (tmp > 0):
        #print(tmp, file=sys.stderr)
        A[x].pop(di)
        A[y].insert(d0i+1, d)
        X[d] = y
        max_score += tmp
#print(max_score, file=sys.stderr)
for x in X:
    print(x+1)


Measured memory_bytes: 81660
#include <iostream>
#include<sstream>
#include<string>
#include<vector>
#include <cmath>
#include <limits>
#include <queue>
#include<algorithm>
#include<cstring>
#include <cstdlib>
#include <cstdio>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <memory>
#include <numeric>
#include <type_traits>
 
using namespace std;
 
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
typedef long long ll;
vector<int> prime, res;
const int VMAX = 100100;

bool is_prime(int num){
    if (num < 2) return false;
    else if (num == 2 || num == 3) return true;
    rep(i,prime.size()){
        if (num%prime[i] == 0) return false;
    }
    int temp = prime.back();
    while (temp < num){
        if (num%temp == 0) return false;
        ++temp;
    }
    return true;
}

void make_primes(){
    rep(i,VMAX+1){
        if (is_prime(i)) prime.push_back(i);
    }
}



 
int main() {
    int x;
    cin >> x;
    make_primes();
    
    int i = 0;
    while(prime[i] < x){
        ++i;
    }
    cout << prime[i] << endl;

    return 0;
}

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

void output_array(int arr[], int arr_len)
{
  cout << arr[0];
  for (int i = 1; i < arr_len; ++i)
  {
    cout << ' ' << arr[i];
  }
  cout << endl;
}

void insertion_sort(int arr[], int arr_len)
{
  int i = 0;
  int j = 0;
  int cur_value = 0;

  output_array(arr, arr_len);

  for (i = 1; i < arr_len; ++i)
  {
    cur_value = arr[i];
    j = i - 1;

    while (j >= 0 && arr[j] > cur_value)
    {
      arr[j + 1] = arr[j];
      --j;
    }

    arr[j + 1] = cur_value;
    output_array(arr, arr_len);
  }
}

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

  // Initialization of nums array
  int nums[n];
  int cur_num;
  for (int i = 0; i < n; ++i)
  {
    cin >> cur_num;
    nums[i] = cur_num;
  }

  insertion_sort(nums, n);

  return 0;
}


Measured memory_bytes: 3076