akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
bool comp(pair<long long int,long long int>a,pair<long long int,long long int>b)
{
    if(a.first==b.first)
    {
        if(a.second<=b.second)
        return true;
        else
        return false;
    }
    if(a.first>b.first)
    return true;
    else return false;
}
bool compa(pair<string,pair<int,int>>a,pair<string,pair<int,int>>b)
{
    if(a.first==b.first)
    {
        if(a.second.first>b.second.first)
        return true;
        else
        return false;
    }
    if(a.first<b.first)
    return true;
    else 
    return false;
}
long long int gcd(long long int bdda,long long int chota)
{
    if(chota==0)
        return bdda;
    return gcd(chota,bdda%chota);
}
void solve()
{
    int n,m;
    cin>>n>>m;
    map<int,vector<string>>mp;
    for(int i=0;i<m;i++)
    {
        int num;string s;
        cin>>num>>s;
        mp[num].push_back(s);
    }
    int ac=0,wa=0;
    for(auto x:mp)
    {
        int count=0,flag=0;
        for(auto y:x.second)
        {
            if(y=="WA" && flag==0)
            count++;
            if(y=="AC")
            {
                flag=1;
                break;
            }
        }
        if(flag)
        {ac++;wa+=count;}
    }
    cout<<ac<<" "<<wa;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;    
    t=1;

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


Measured memory_bytes: 15972
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
# 約数列挙
def find_divisor(n):
    divisors=[]
    for i in range(1, int(sqrt(n)) + 1):
        if n % i == 0:
            divisors.append(i)
            divisors.append(n // i)
    return divisors


# 素因数分解
def prime_factorization(n):
    fact=[]
    for i in range(2, int(sqrt(n)) + 1):
        while n % i == 0:
            n //= i
            fact.append(i)
    return fact

def main():
    N,M= MI()
    P = find_divisor(M)
    ans = 1
    for p in P:
        if M/p>=N:
            ans = max(ans,p)
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n, temp;
  set<int> s;

  cin >> n;
  REP(i,n){
    cin >> temp; 
    s.insert(temp);
  }
  cout << s.size() << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
count = 0
for i in range(n):
    if b[i] <= a[i]:
        count += b[i]
    else:
        p = b[i]-a[i]
        count += a[i]
        if p > a[i+1]:
            count += a[i+1]
            a[i+1] = 0
        else:
            count += p
            a[i+1] -= p
print(count)

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

using namespace std;

int main()
{
    map<long long,long long> ma;
    long long n,sum=0;
    cin>>n;
    for(long long i=0; i<n; i++){
        long long in;
        cin>>in;
        sum+=in;
        ma[in]++;
    }
    long long q;
    cin>>q;
    for(long long i=0; i<q; i++){
        long long b,c;
        cin>>b>>c;
        sum+=ma[b]*(c-b);
        ma[c]+=ma[b];
        ma[b]=0;
        cout<<sum<<"\n";
    }
}


Measured memory_bytes: 9368
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
int main() {
    int N; cin >> N;
    int p = 1, ans = 0;
    for(int i=1; i<=5; i++) {
        int lo = p - 1, hi = p * 10 - 1;
        if(i % 2 == 1) {
            hi = min(hi, N);
            if(hi >= lo) ans += hi - lo;
        }
        p *= 10;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    
    int A, B, sum=0;
    scanf("%d%d", &A, &B);
    
    char S[A+B+1];
    scanf("%s", S);
    
    for(int i=0;i<A;i++){
    	if(S[i]<48 || S[i]>57){
    		printf("No");
    		return 0;
		}
	}
	if(S[A] != '-'){
		printf("No");
    	return 0;
	} 
	for(int i=A+1;i<A+B+1;i++){
    	if(S[i]<48 || S[i]>57){
    		printf("No");
    		return 0;
		}
	}
	printf("Yes");
    return 0;
}

Measured memory_bytes: 1724
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    ll n;
    scanf("%lld", &n);
    vector<ll> a(n),b(n),c(n);
    for(int i = 0; i < n; i++)
    scanf("%lld",&a[i]);
    for(int i = 0; i < n; i++)
    scanf("%lld",&b[i]);
    for(int i = 0; i < n; i++)
    scanf("%lld",&c[i]);
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    ll sum = 0;
    for(int i = 0; i < n; i++){
        auto Itera = upper_bound(a.begin(),a.end(),b[i] - 1);
        auto Iterc = lower_bound(c.begin(),c.end(),b[i] + 1);
        sum += (Itera - a.begin()) * (c.end() - Iterc);
    }
    printf("%lld\n", sum);
}

Measured memory_bytes: 2560
import java.util.Scanner;
import java.util.Arrays;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Time[][] TimeArray = new Time[3][8];
		Time[] ThirdTimeArray = new Time[6];
		
		for(int i = 0; i < 3; i++){
			for(int j = 0; j < 8; j++){
				TimeArray[i][j] = new Time(sc.nextInt(), sc.next());
			}
		}
		for(int i = 0; i < 3; i++){
			Arrays.sort(TimeArray[i]);
		}
		for(int i = 0; i < 3; i++){
			for(int j = 0; j < 2; j++){
				System.out.println(TimeArray[i][j]);
			}
		}
		int tta = 0;
		int ta = 0;
		while(tta < 6){
			ThirdTimeArray[tta] = TimeArray[ta][2];
			ThirdTimeArray[tta + 1] = TimeArray[ta][3];
			tta += 2;
			ta++;
		}
		Arrays.sort(ThirdTimeArray);
		System.out.println(ThirdTimeArray[0]);
		System.out.println(ThirdTimeArray[1]);
	}
}

class Time implements Comparable<Time>{
	int id;
	String time;
	Time(int id, String time){
		this.id = id;
		this.time = time;
	}
	@Override
	public String toString(){
		return id + " " + time;
	}
	@Override
	public int compareTo(Time t){
		return time.compareTo(t.time);
	}
}

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

using namespace std;

int main(){
  int n; cin >> n;
  int a[n+1];
  vector<int> v;
  for(int i=1;i<=n;i++){
    cin >> a[i];
    if(i==a[i]) v.push_back(a[i]);
  }
  int ans=0;
  int i=0;
  while(i<v.size()){
    if(i!=v.size()-1 && v[i]+1==v[i+1]){
      ans++;
      i=i+2;
    }else{
      ans++;
      i=i+1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1148
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define eb emplace_back
#define precision(n) cout << fixed << setprecision(n);
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
int main()
{
    fast;
    int k;
    cin>>k;
    string s;
    cin>>s;
    int p=s.size();
   // cout<<p<<endl;
    if(p<=k)
    {
        cout<<s<<endl;
    }

    else
    {
        for(int i=0;i<k;i++)
        {
            cout<<s[i];
        }
        cout<<"..."<<endl;
    }
    return 0;

}



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

ll oddsolve(ll a){
    return (a+1)/2%2;
}

ll solve(ll a){
    if(a%2==1) return oddsolve(a);
    else return oddsolve(a+1)^(a+1);
}

int main(){
    ll A,B; cin>>A>>B;
    cout<<(solve(B)^solve(A-1))<<endl;
}

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

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n, d;
  cin >> n >> d;
  vector <vector <ll>> v(n, vector <ll> (d));
  rep(i, n) {
    rep(j, d) {
      cin >> v.at(i).at(j);
    }
  }
  ll res = 0;
  rep(i, n) {
    for (ll j = i+1; j < n; j++) {
      ll tmp = 0;
      rep(k, d) {
        tmp += pow(v.at(i).at(k)-v.at(j).at(k), 2);
      }
      if (tmp == (ll)pow((ll)pow(tmp, 0.5), 2)) res++;
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <sstream>
#include <set>
using namespace std;

const int mmod = 1000000007;

int prv[1<<18], nxt[1<<18];

int main()
{
  int n, x, y, z;
  cin >> n >> x >> y >> z;
  prv[0] = 1;

  int sum = x+y+z;

  for (int iter=0; iter<n; iter++) {
    for (int i=0; i<(1<<sum); i++)
      nxt[i] = 0;

    for (int i=0; i<(1<<sum); i++) {
      for (int add=1; add<=10; add++) {
        int bit = 0;
        if (i&(1<<(sum-1))) bit = 1<<(sum-1);
        if (add <= x) bit |= 1<<(add-1);

        for (int j=1; j+add <= x; j++) {
          if (!(i&(1<<(j-1)))) continue;
          int k = j + add;
          bit |= 1<<(k-1);
        }

        for (int j=x; j+add <= x+y; j++) {
          if (!(i&(1<<(j-1)))) continue;
          int k = j + add;
          bit |= 1<<(k-1);
        }

        for (int j=x+y; j+add <= x+y+z; j++) {
          if (!(i&(1<<(j-1)))) continue;
          int k = j + add;
          bit |= 1<<(k-1);
        }
        
        nxt[bit] += prv[i];
        if (nxt[bit] >= mmod) nxt[bit] -= mmod;
      }
    }
    
    for (int i=0; i<(1<<sum); i++)
      prv[i] = nxt[i];
  }

  int ret = 0;
  for (int i=0; i<(1<<sum); i++)
    if (i&(1<<(sum-1))) ret = (ret + prv[i]) % mmod;

  printf("%d\n", ret);
}


Measured memory_bytes: 1280
n = int(input())
h = list(map(int, input().split()))
count = 0
saidai = 0
for i in range(n-1):
    if h[i] >= h[i+1]:
        count += 1
    else:
        if count > saidai:
            saidai = count
        count = 0
    if count > saidai:
        saidai = count
print(saidai)

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

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

  int num = 1;
  for(int i = 0; i < N; i++){
    if(num * 2 < num + K)
      num *= 2;
    else
        num += K;
  }

  cout << num << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep0(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define mREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int main(){
  int n,x;
  cin>>n>>x;
  int temp = 0;
  int ans = 0;
  rep0(i,n){
    cin>>temp;
    if(i == 0)ans = abs(temp-x);
    else{
      ans = gcd(ans,abs(temp-x));
    } 
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000000)
x = input()
n = len(x)
ans = "NO"

def f(i):
    if n==i:
        global ans
        ans = "YES"
    else:
        if x[i:i+5] == "dream":
            f(i+5)
        if x[i:i+7] == "dreamer":
            f(i+7)
        if x[i:i+5] == "erase":
            f(i+5)
        if x[i:i+6] == "eraser":
            f(i+6)
f(0)
print(ans)

Measured memory_bytes: 51824
#include <iostream>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
#include <vector>
//#include <unordered_map>
//#include <string>
//typedef long long LL;
//typedef long double LD;
using namespace std;

int main() {
    int n;
    vector<int> p;
    vector<int> q;
    int tmp_p;
    int tmp_q;
    int ans_p=1;
    int ans_q=1;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> tmp_p;
        p.push_back(tmp_p);
    }
    for(int i=0; i<n; i++){
        cin >> tmp_q;
        q.push_back(tmp_q);
    }

    int tmp;
    for(int i=0; i<n-1; i++){
        tmp=0;
        for(int j=i+1; j<n; j++){
            if(p[i]>p[j]){
                tmp++;
            }
        }
        for(int k=n-1-i; k>=1; k--){
            tmp *= k;
        }
        ans_p += tmp;
    }
    for(int i=0; i<n-1; i++){
        tmp=0;
        for(int j=i+1; j<n; j++){
            if(q[i]>q[j]){
                tmp++;
            }
        }
        for(int k=n-1-i; k>=1; k--){
            tmp *= k;
        }
        ans_q += tmp;
    }
    //cout << ans_p << " " << ans_q << endl;
    cout << abs(ans_p-ans_q) << endl;
    return 0;
}

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

#define x first
#define y second
#define pb push_back
#define mp make_pair

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

#define ll long long

int k;
ll a[100000];

bool ok(ll n) {
    for (int i=0; i<k; i++) {
        n -= n%a[i];
    }
    return n>=2;
}

bool ok1(ll n) {
    for (int i=0; i<k; i++) {
        n -= n%a[i];
    }
    return n<=2;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> k;
    for (int i=0; i<k; i++) {
        cin >> a[i];
    }
    ll lo = 0, hi = 2e18+21;
    while (hi-lo > 1) {
        ll mi = (lo+hi)/2;
        if (ok(mi)) {
            hi = mi;
        } else {
            lo = mi;
        }
    }
    ll ansl = hi;
    lo = 0, hi = 2e18+21;
    while (hi-lo > 1) {
        ll mi = (lo+hi)/2;
        if (ok1(mi)) {
            lo = mi;
        } else {
            hi = mi;
        }
    }
    ll ansr = lo;
    if (ansl > ansr) {
        cout << "-1\n";
    } else {
        cout << ansl << " " << ansr << '\n';
    }
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    string S;
    cin >> S;
    cout << S.substr(0,3) << endl;
}


Measured memory_bytes: 3628
#include <stdio.h>

int
main()
{
	int a, b, c;
	char op;
	for (;;)
	{
		scanf("%d %c %d", &a, &op, &b);

		if (op == '?')
			break;

		switch (op)
		{
		case '+': c = a + b; break;
		case '-': c = a - b; break;
		case '*': c = a * b; break;
		case '/': c = a / b; break;
		}
		printf("%d\n", c);
	}

	return 0;
}

Measured memory_bytes: 600
from collections import deque 
#スタック
s = deque([])

N,M=map(int,input().split())
G = [[] for i in range(N+1)]

LRD = []
for i in range(M):
    L,R,D = map(int,input().split())
    G[L].append([R,D])
    G[R].append([L,-D])

ans = True
X = [None]*(N+1)
for i in range(1,N+1):

    if X[i]==None:
        s.append([i,0])

    while len(s)>0:#dfs
        j,x = s.pop()
        if X[j]==None:
            X[j]=x
            for nex in G[j]:
                s.append([nex[0],x+nex[1]])
        else:
            if X[j]!=x:
                ans = False
                break

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

Measured memory_bytes: 149936
H,N = map(int, input().strip().split())
M = [list(map(int, input().strip().split())) for _ in range(N)]

tb = [float('inf')]*(H+1)
tb[0] = 0
for a,b in M:
  for i in range(1,min(H+1,a+1)):
    tb[i] = min(tb[i], b)
  for i in range(H+1-a):
    tb[i+a] = min(tb[i+a], tb[i]+b)
  #print(tb)

print(tb[-1])

Measured memory_bytes: 49244
#include<iostream>
using namespace std;
int main(){
	int n,m,sum=0;
	cin>>n>>m;
	for(int i=1;i<n;i++){
		sum+=i;
	}
	for(int i=1;i<m;i++){
		sum+=i;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
# https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/11/ALDS1_11_B
# 本の解説通りかは知らない

# データの読み込み
N = int(input())
DG = {}
node_ls = []
is_visited = {}
# 有向グラフをディクトで管理することにする
for _ in range(N):
    tmp = input().split()
    node_id = tmp[0]
    node_ls.append(node_id)
    is_visited[node_id] = False
    adj_num = int(tmp[1])
    if adj_num != 0:
        DG[node_id] = tmp[2:]
    else:
        DG[node_id] = []

d = {}  # 最初に訪問したときの発見時刻を記録する
f = {}  # 隣接リストを調べ終えた完了時刻を記録する
t = 1


def dfs(node):  # 必要なものは何？ 現在のノード
    # 終了条件
    global t
    if is_visited[node]:
        return  # 何もせずに上の関数に抜ける

    is_visited[node] = True
    # 発見時刻の書き込み
    d[node] = t
    t += 1  # 時刻を一つ進める
    # 再帰探索
    for no in DG[node]:
        dfs(no)
    f[node] = t
    t += 1  # 関数を終了するときにも+1する


for node in node_ls:  # 孤立しているノードもあるためこうして対処
    dfs(node)

for node in node_ls:
    print(node, d[node], f[node])



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

int main()
{
    int N, M;
    cin >> N >> M;
    vector<string> A(N);
    vector<string> B(M);
    rep (i, N) { cin >> A[i]; }
    rep (i, M) { cin >> B[i]; }

    rep (ay, N - M + 1)
    {
        rep (ax, N - M + 1)
        {
            int cnt = 0;
            rep (by, M)
            {
                rep (bx, M)
                {
                    if (A[ay+by][ax+bx] == B[by][bx])
                    {
                        cnt++;
                    }
                }
            }
            if (cnt == M*M)
            {
                cout << "Yes" << "\n";
                return 0;
            }
        }
    }

    cout << "No" << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
	char c;
	while(1){
    	scanf("%c",&c);
    	if(isalpha(c) ){
    		if("%c",isupper(c) ) printf("%c", tolower(c));
    		else if("%c",islower(c) )printf("%c", toupper(c));
    	}else printf("%c", c);

    	if(c == '\n') break;
	}
    return 0;
}


Measured memory_bytes: 3148
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#define my_abs(x) ((x) < 0 ? -(x) : (x))
#define mp make_pair
#define pb push_back
#define X first
#define Y second
using namespace std; 
typedef long long ll; 
bitset<4000005> mask(1); 
int main()
{
	// freopen("AGC020-C.in", "r", stdin); 
	int n, sum = 0; 
	scanf("%d", &n); 
	for (int i = 0; i < n; i++)
	{
		int x; 
		scanf("%d", &x); 
		mask |= mask << x; 
		sum += x; 
	}
	for (int i = sum + 1 >> 1; ; i++)
	{
		if (mask.test(i))
		{
			printf("%d\n", i);
			return 0; 
		}
	}
	return 0; 
}


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

int main() {
    int N;
    int res=1001001001;
    cin >> N;
    vector<int> X(N);
    for (int i=0;i<N;i++){
        cin >> X[i];
    }

    for (int i=0;i<100;i++){
        int sum=0;
        for (int j=0;j<N;j++){
            sum+=((X[j]-i)*(X[j]-i));
        }
        res = min(res,sum);
    }

    cout << res << endl;
}

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

int main(){
	
	int N, Y, ans=1001;
	cin >>N >>Y;
	
	vector<pair<int, int>> CT(N);
	
	for(int i=0; i<N; i++){
		
		cin >>CT.at(i).first >>CT.at(i).second;
		
	}
	
	for(int i=0; i<N; i++){
		
		if(Y>=CT.at(i).second){
			
			ans=min(CT.at(i).first, ans);
			
		}
		
	}
	if(ans<=1000){
		
		cout << ans <<endl;
		
	}
	else{
		
		cout <<"TLE" <<endl;
		
	}
	
}



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

int main(void){
    long long n,q[5]={1,2,4,8};
    vector<pair<long long,long long>> vp(4);
    for(int i=0;i<4;i++){
        cin>>vp[i].first;
        vp[i].second=q[i];
        vp[i].first*=8/q[i];
    }
    cin>>n;
    n*=4;
    sort(vp.begin(),vp.end());
    long long ans=0;
    for(int i=0;i<4;i++){
        ans+=(n/vp[i].second)*vp[i].first/(8/vp[i].second);
        n-=(n/vp[i].second)*vp[i].second;
    }
    cout<<ans<<endl;
    return 0;
}


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

const int inf = int (1e9) + 7;
const long long INF = 1e18;
const double eps = 1e-9;

using namespace std;

int main(){
	#ifdef nurik
	freopen ("in", "r", stdin);
	#endif

	ios_base::sync_with_stdio(0);

	int n, k, s;

	cin >> n >> k >> s;

	for(int i=1; i<=k; ++i){
		cout << s << " ";
	}

	for(int i=1; i<=n - k; ++i){
		if(s != int(1e9)){
			cout << s + 1 << " ";
		} else{
			cout << s - 1 << " ";
		}
	}

	return 0;
}


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

int main()
{
  ll n;
  cin >> n;
  vector<ll> v(n, 0);
  for (ll i = 0; i < n - 1; i++)
  {
    ll a;
    cin >> a;
    v[a - 1]++;
  }
  for (ll i = 0; i < n; i++)
  {
    cout << v[i] << endl;
  }
}


Measured memory_bytes: 4844
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

/* define */
#define Yes(X) puts ( X ? "Yes" : "No")
#define YES(X) puts ( X ? "YES" : "NO")
#define FOR(i, a, b) for ( int i = a; i < b ; i++)
#define REP(i, n) for ( int i = 0; i < n ; i++)
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max3(a, b, c) ((max((a), (b)) > (c)) ? max((a), (b)) : (c))
#define min3(a, b, c) ((min((a), (b)) < (c)) ? min((a), (b)) : (c))

/* const */
const int MOD = (int)1e9 + 7;

/* alias */
typedef long long ll;
typedef unsigned  u;

/* function */
int cmp(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int cmp2(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
ll Lgcd(ll a, ll b) {
	if (b != 0) return Lgcd(b, a % b); 
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
ll Llcm(ll a, ll b) {
	return a / Lgcd(a, b) * b;
}

/* main */

int main() {
	int info[100][10], prof[100][11];
	int n, ans = -1e9, count, point;
	scanf("%d", &n);
	REP(i, n)REP(j, 10) scanf("%d", &info[i][j]);
	REP(i, n)REP(j, 11) scanf("%d", &prof[i][j]);
	for (int b = 1; b < (1<<10); b++) {
		point = 0;
		REP(i, n) {
			count = 0;
			REP(j, 10) if ((b >> j & 1) && info[i][j])count++;
			point += prof[i][count];
		}
		ans = max(ans, point);
	}
	printf("%d", ans);
	return 0;
}

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

int main() {
  string s; cin>>s;
  if(s[5] == '1') cout << "TBD" << endl;
  else if(s[6] < '5') cout << "Heisei" << endl;
  else cout << "TBD" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)

ll c[10000][10000];
bool v[10000];
ll N, M;
ll cnt = 0;

bool ifallvisited() {
	bool valid = true;
	rep(i, 0, N) {
		valid &= v[i];
	}
	return valid;
}

void dfs(int id) {
	if (ifallvisited()) {
		cnt++;
		return;
	}

	rep(i, 0, N) {
		if (id != i && c[id][i] != 0 && !v[i]) {
			v[i] = true;
			dfs(i);
			v[i] = false;
		}
	}
}

int main() {
	cin >> N >> M;
	rep(i, 0, M) {
		int a, b; cin >> a >> b;
		c[a - 1][b - 1] = 1;
		c[b - 1][a - 1] = 1;
	}

	v[0] = true;
	dfs(0);

	cout << cnt << endl;
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    int max = 0;
    int sum = 0;
    int tmp;
    for (int i=0; i<N; i++) {
        cin >> tmp;
        sum += tmp;
        if (tmp > max) {
            max = tmp;
        }
    }
    cout << sum-max/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

int main() {

  int n, t, a;
  cin >> n >> t >> a;
  vector<double> v;
  for (int i = 0; i < n; i++) {
    int c;
    cin >> c;
    v.push_back(abs(t - 0.006 * c - a));
  }
  cout << (min_element(v.begin(), v.end()) - v.begin() + 1);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main()
{
    int n;
    cin >> n;
    vector<pii> student;
    rep(i, 0, n)
    {
        int a;
        cin >> a;
        student.emplace_back(a, i+1);
    }
    sort(student.begin(), student.end());
    rep(i, 0, n)
        cout << student[i].second << ' ';
    cout << endl;

    return 0;
}

Measured memory_bytes: 1780
#include<bits/stdc++.h>
using namespace std;
#define n_l '\n'
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]: "; cerr << to_string(__VA_ARGS__) << endl
template <typename T, size_t N> int SIZE(const T (&t)[N]){ return N; } template<typename T> int SIZE(const T &t){ return t.size(); } string to_string(const string s, int x1=0, int x2=1e9){ return '"' + ((x1 < s.size()) ? s.substr(x1, x2-x1+1) : "") + '"'; } string to_string(const char* s) { return to_string((string) s); } string to_string(const bool b) { return (b ? "true" : "false"); } string to_string(const char c){ return string({c}); } template<size_t N> string to_string(const bitset<N> &b, int x1=0, int x2=1e9){ string t = ""; for(int __iii__ = min(x1,SIZE(b)),  __jjj__ = min(x2, SIZE(b)-1); __iii__ <= __jjj__; ++__iii__){ t += b[__iii__] + '0'; } return '"' + t + '"'; } template <typename A, typename... C> string to_string(const A (&v), int x1=0, int x2=1e9, C... coords); int l_v_l_v_l = 0, t_a_b_s = 0; template <typename A, typename B> string to_string(const pair<A, B> &p) { l_v_l_v_l++; string res = "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; l_v_l_v_l--; return res; } template <typename A, typename... C> string to_string(const A (&v), int x1, int x2, C... coords) { int rnk = rank<A>::value; string tab(t_a_b_s, ' '); string res = ""; bool first = true; if(l_v_l_v_l == 0) res += n_l; res += tab + "["; x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v)); auto l = begin(v); advance(l, x1); auto r = l; advance(r, (x2-x1) + (x2 < SIZE(v))); for (auto e = l; e != r; e = next(e)) { if (!first) { res += ", "; } first = false; l_v_l_v_l++; if(e != l){ if(rnk > 1) { res += n_l; t_a_b_s = l_v_l_v_l; }; } else{ t_a_b_s = 0; } res += to_string(*e, coords...); l_v_l_v_l--; } res += "]"; if(l_v_l_v_l == 0) res += n_l; return res; } void dbgm(){;} template<typename Heads, typename... Tails> void dbgm(Heads H, Tails... T){ cerr << to_string(H) << " | "; dbgm(T...); } 
#define dbgm(...) cerr << "[" << #__VA_ARGS__ << "]: "; dbgm(__VA_ARGS__); cerr << endl
#define run(a, b) cerr << fixed << setprecision(6) << (double) (b - a) / (double) (CLOCKS_PER_SEC) << " s" << endl;
#define ll long long
#define ld long double
#define INF (1e18L + 5)
#define MOD (ll)(1e9 + 7)

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll a;
    cin >> a;
    ll ans = INF;
    for(ll i = 1; i * i <= a; i++) {
        if(a % i == 0) {
            ll j = a / i;
            ans = min(j - 1 + i - 1, ans);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define mod 1000000007 
#define check exit(0)
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define trace(x) cerr<<#x<<" : "<<x<<endl;
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace __gnu_pbds;
using namespace std;

int main()
{
    jaldi
    int n;
    cin>>n;
    cout<<n/2+n%2;
    return 0;
}


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

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

  map<char, int> cnt;

  for (int i = 0; i < str.size(); i++) {
    cnt[str[i]]++;
  }

  for (auto x : cnt) {
    if (x.second % 2 != 0) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define all(a) (a).begin(),(a).end()
#define X first
#define Y second
#define inf 2e9+5
using namespace std;
const int N=3005;
double p[N],dp[N];
double ans;
void solve()
{
  int n; cin>>n;
  for(int i=0;i<n;i++)cin>>p[i];
  dp[1]=1-p[0]; dp[0]=p[0];
  for(int i=1;i<n;i++)
  {
      for(int j=n/2;j>=0;j--)
      {
          if(j!=0)dp[j]=dp[j-1]*(1-p[i])+dp[j]*p[i];
          else dp[0]=dp[0]*p[i];
      }
  }
  for(int i=0;i<=n/2;i++)ans+=dp[i];
  printf("%0.9f",ans);
  return;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t; t=1;
    while(t--)solve();
    return 0;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MAX_N 100'000
vector<i64> G[MAX_N];

int main() {
    i64 N, M; cin >> N >> M;
    REP(i, M) {
        i64 u, v; cin >> u >> v;
        u--; v--;
        G[u].pb(v);
        G[v].pb(u);
    }

    vector<i64> d(N, -1);
    queue<i64> que;

    d[0] = 0;
    que.push(0);
    vector<i64> mark(N);
    while (!que.empty()) {
        i64 u = que.front(); que.pop();
        
        for (i64 v : G[u]) {
            if (d[v] != -1) continue;
            mark[v] = u;
            d[v] = d[u] + 1;
            que.push(v);
        }
    }

    cout << "Yes" << endl;
    for (i64 i = 1; i < N; i++) {
        cout << (mark[i] + 1) << endl;
    }

    return 0;
}

Measured memory_bytes: 13664
module mod_bounding_box
  implicit none
  real(8), parameter :: infty = 1.e12
  type :: bounding_box
    real(8) :: l(-1:1), r(-1:1)
  end type bounding_box
  private
  public :: infty
  public :: mins, maxs
  public :: bounding_box, init, add, get, event
contains
  subroutine mins(x,y)
    implicit none
    real(8), intent(inout) :: x
    real(8), intent(in) :: y
    x = min(x,y)
    return
  end subroutine mins
  subroutine maxs(x,y)
    implicit none
    real(8), intent(inout) :: x
    real(8), intent(in) :: y
    x = max(x,y)
    return
  end subroutine maxs
  subroutine init(bb)
    implicit none
    type(bounding_box), intent(inout) :: bb
    bb%l = infty
    bb%r = -infty
    return
  end subroutine init
  subroutine add(bb,z,i)
    implicit none
    type(bounding_box), intent(inout) :: bb
    real(8), intent(in) :: z
    integer :: i
    call mins(bb%l(i),z)
    call maxs(bb%r(i),z)
    return
  end subroutine add
  function get(bb,t) result(d)
    implicit none
    type(bounding_box), intent(in) :: bb
    real(8), intent(in) :: t
    real(8) :: d, l, r
    integer :: i
    l = infty
    r = -infty
    do i = -1, 1
      call mins(l,bb%l(i)+real(i,8)*t)
      call maxs(r,bb%r(i)+real(i,8)*t)
    end do
    d = r-l
    return
  end function get
  function event(bb) result(t)
    implicit none
    type(bounding_box), intent(in) :: bb
    real(8) :: t(6)
    t(1) = bb%l(-1)-bb%l(0)
    t(2) = 0.5d0*(bb%l(-1)-bb%l(1))
    t(3) = bb%l(0)-bb%l(1)
    t(4) = bb%r(-1)-bb%r(0)
    t(5) = 0.5d0*(bb%r(-1)-bb%r(1))
    t(6) = bb%r(0)-bb%r(1)
    return
  end function event
end module mod_bounding_box
program minimum_bounding_box
  use mod_bounding_box
  implicit none
  integer :: n, i
  real(8) :: x, y, ans, events(14)
  type(bounding_box) :: xbb, ybb
  character(1) :: d
  character(64) :: s
  call init(xbb)
  call init(ybb)
  events = 0.d0
  read(*,*) n
  do i = 1, n
    read(*,*) x, y, d
    select case(d)
    case("R")
      call add(xbb,x,1)
      call add(ybb,y,0)
    case("L")
      call add(xbb,x,-1)
      call add(ybb,y,0)
    case("U")
      call add(xbb,x,0)
      call add(ybb,y,1)
    case("D")
      call add(xbb,x,0)
      call add(ybb,y,-1)
    end select
  end do
  events(1:6) = event(xbb)
  events(7:12) = event(ybb)
  events(13) = 0.d0
  events(14) = infty
  ans = infty**3
  do i = 1, 14
    if (events(i).lt.0.d0) cycle
    call mins(ans,get(xbb,events(i))*get(ybb,events(i)))
  end do
  write(s,'(f40.16)') ans
  write(*,'(a)') trim(adjustl(s))
  stop
end program minimum_bounding_box

Measured memory_bytes: 256
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]
    a = f()

    cntp = 0
    cntn = 0
    cnt0 = 0

    total = 0
    miabs = int(1e10)
    for i in range(n):
        total += abs(a[i])
        miabs = min(miabs, abs(a[i]))
        if a[i]>0:
            cntp += 1
        elif a[i] < 0:
            cntn += 1
        else:
            cnt0 += 1
    

    if cntn%2 == 0 or cnt0 > 0:
        print(total)
    else:
        print(total - 2*miabs)


solve()


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

//定数
//円周率
const double pi = 3.141592653589793238462643383279;
//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 100000000000000000; // = 10^17
//ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";
//よくあるmodくん
const ll MOD = 1000000007; // = 10^9 + 7
//前処理テーブルの大きさ指定
const int MAX = 1200000; // = 10^6 + 2*(10^5)
//ちなみに、1024MBで持てる最大長の配列は10^8程度

//データ構造
//隣接リスト用構造体（有向グラフ向け）
struct edge {
  ll to; // E.toでその辺の終点へアクセスできる。
  ll cost; // e.costでその辺の重みにアクセスできる。
};
//Union_Find木
struct UnionFind {
  vector<int> UF; // UF.at(i) : iの親の番号
  vector<int> SIZE; // SIZE.at(root(i)) : iと連結されてる要素の数
  UnionFind(int N) : UF(N), SIZE(N, 1) { // 最初は全てが根であるとして初期化
    for(int i = 0; i < N; i++) {
      UF.at(i) = i;
    }
  }
  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (UF.at(x) == x) {
      return x;
    }
    return UF.at(x) = root(UF.at(x));
  }
  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); // xの根をrx
    int ry = root(y); // yの根をry
    if (rx == ry) {
      return; // xとyの根が同じ(=同じ木にある)時はそのまま
    }
    // xとyの根が同じでない(=同じ木にない)時：小さい方の根を大きい方の根につける。
    if (SIZE.at(rx) < SIZE.at(ry)) {
      UF.at(rx) = ry;
      SIZE.at(ry) += SIZE.at(rx);
      SIZE.at(rx) = 0;
    }
    else {
      UF.at(ry) = rx;
      SIZE.at(rx) += SIZE.at(ry);
      SIZE.at(ry) = 0;
    }
  }
  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す。
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
  int size(int x) { // xと連結されてる要素の数を返す。
    return SIZE.at(root(x));
  }
};

//関数 (計算量)
//ctoi (O(1))
int ctoi(char c){
  if (c == '0') return 0;
  if (c == '1') return 1;
  if (c == '2') return 2;
  if (c == '3') return 3;
  if (c == '4') return 4;
  if (c == '5') return 5; 
  if (c == '6') return 6;
  if (c == '7') return 7;
  if (c == '8') return 8;
  if (c == '9') return 9;
  return -1;  
}
//to_char (O(1))
char to_char(int i){
  if (i == 0) return '0';
  if (i == 1) return '1';
  if (i == 2) return '2';
  if (i == 3) return '3';
  if (i == 4) return '4';
  if (i == 5) return '5';
  if (i == 6) return '6';
  if (i == 7) return '7';
  if (i == 8) return '8'; 
  if (i == 9) return '9';
  return ' ';  
}

//A^N mod M を計算する。modしたくなかったらpow使うかM = LINFとかにすればよい。(O(√N))
ll modpow(ll A, ll N, ll M) {
  ll ans = 1;
  while (N > 0) {
    if (N & 1) ans = ans * A % M;
      A = A * A % M;
      N >>= 1;
   }
  return ans;
}

//メイン処理
int main() {
  cout << fixed << setprecision(16); //精度向上
  //ここまでテンプレ
  ll N, A, B;
  cin >> N >> A >> B;
  ll ans = modpow(2, N, MOD);
  ll AX = 1, BX = 1, AY = 1, BY = 1;
  for (int i = 1; i <= A; i++) {
    AY *= i;
    AY %= MOD;
    AX *= (N - i + 1);
    AX %= MOD;
  }
  for (int i = 1; i <= B; i++) {
    BY *= i;
    BY %= MOD;
    BX *= (N - i + 1);
    BX %= MOD;
  }
  ans -= 1;
  ans -= (AX * modpow(AY, MOD - 2, MOD)) % MOD;
  ans -= (BX * modpow(BY, MOD - 2, MOD)) % MOD;
  ans += 3 * MOD;
  ans %= MOD;
  cout << ans << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>
 
int main()
{
    int n, d[100], s = 1, tmp, cnt = 0;

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

    while(1){
        cnt = 0;
        for(int i = 0;i < n - 1;i++){
            if(d[i] > d[i + 1]){
                tmp = d[i + 1];
                d[i + 1] = d[i];
                d[i] = tmp;
                cnt++;
            }
        }
        if(cnt == 0){
            break;
        }
    }

    for(int i = 0;i < n - 1;i++){
        if(d[i] != d[i + 1]){
            cnt++;
        }
    }

    if(cnt == 0){
        cnt = 1;
    }
    else{
        cnt++;
    }

    std::cout << cnt;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <fstream>

using namespace std;

int n, m;

int main(){
  cin>>n>>m;
  if(n<m){
    for(int i=0;i<m;i++){
      cout<<n;
    }
  
    
  }
  else{
    for(int i=0;i<n;i++){
      cout<<m;
    }
  }
}

Measured memory_bytes: 256
N, Y = map(int, input().split())
x = -1
y = -1
z = -1
for i in range(N + 1):
    for j in range(N - i + 1):
        if 10000 * i + 5000 * j + 1000 * (N - i - j) == Y:
            x = i
            y = j
            z = N - i - j
            break
print(x, y, z)

Measured memory_bytes: 9136
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long ans=0;
	int N, K;
	int v[200005];
	scanf("%d %d", &N, &K);
	for (int i = 0; i < N; i++) {
		scanf("%d", &v[i]);
	}
	sort(v, v + N);
	for (int i =N-K-1; i>=0; i--) ans += v[i];
	cout << ans << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <iomanip>
#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

class Union_Find {
    public:
    std::vector<int> par;
    Union_Find() {}
    Union_Find(int n){
        par.resize(n, 0);
        for(int i = 0; i < n; i++){
            par[i] = i;
        }
    }

    void simplify(int x) {
        std::vector<int> path;
        while (par[x] != x) {
            path.push_back(x);
            x = par[x];
        }
        for (int p : path) {
            par[p] = x;
        }
    }
    
    int find(int x){
        simplify(x);
        return par[x];
    }
    
    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if (x != y) {
            par[y] = x;
            // 改造する時は「根になっているノードの親を変更する」という原則が守られていることに注意。
        }
    }
};

const int MAX_N = 100050;
int N;
int a[MAX_N], b[MAX_N];

std::unordered_map<int, std::vector<int>> mp_a, mp_b;
Union_Find uf = Union_Find(MAX_N);

int main(int argc, char **argv) {
    std::cin >> N;

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

    for (int i = 1; i <= N; i++) {
        std::cin >> b[i];
    }

    for (int i = 1; i <= N; i++) {
        a[0] = a[0] ^ a[i];
        mp_a[a[i]].push_back(i);
        mp_b[b[i]].push_back(i);
    }

    mp_a[a[0]].push_back(0);

    for (int i = 1; i <= N; i++) {
        if (mp_a[b[i]].size() < mp_b[b[i]].size()) {
            std::cout << -1 << std::endl;
            return 0;
        }
    }

    int dif_num = 0;
    for (int i = 1; i <= N; i++) {
        if (a[i] != b[i]) {
            dif_num++;
        }
    }

    if (dif_num == 0) {
        std::cout << 0 << std::endl;
        return 0;
    }

    for (int i = 1; i <= N; i++) {
        if (a[i] != b[i]) {
            for (int j : mp_b[a[i]]) {
                if (a[j] != b[j]) {
                    uf.unite(i, j);
                    if (mp_a[a[i]][0] != i) {
                        break;
                    }
                }
            }
        }
    }

    int con_num = 0;
    for (int i = 1; i <= N; i++) {
        if (a[i] != b[i] && uf.find(i) == i) {
            con_num++;
        }
    }

    int ret = dif_num + con_num;

    for (int i = 1; i <= N; i++) {
        if (a[i] != b[i] && b[i] == a[0]) {
            ret--;
            break;
        }
    }

    //if (mp_a[a[0]].size() == mp_b[a[0]].size()) {
    //    ret--;
    //}

    std::cout << ret << std::endl;
    
    return 0;
}

Measured memory_bytes: 19912
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------

int n;

signed main(){
    I(n);
    vi a(n);
    REP(i,n) I(a[i]);
    int ans = 0;
    int base = 1;
    REP(k,60){
        int s = 0;
        REP(i,n) s += (a[i] >> k) & 1;
        int u = n-s;
        ans += s * u % mod * base % mod;
        ans %= mod;

        base = base * 2 % mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <tr1/unordered_map>
#define ri register int
#define ptf printf
using namespace std;
typedef double db;
typedef long double ld;
typedef long long ll;
typedef vector <int> poly;
typedef pair <int, int> pii;
typedef pair <ll, int> pli;
typedef pair <int, ll> pil;
typedef pair <ll, ll> pll;
typedef unsigned long long ulll;
typedef unsigned int uii;
typedef string strr;
#define fi first
#define se second
#define pb push_back
#define ppp pop_back
#define rez resize
const ll Inf = 2e18;
const int rlen = 1 << 20, inf = 0x3f3f3f3f;
char buf[rlen], *ib = buf, *ob = buf;
#define gc() getchar()//(((ib == ob) && (ob = (ib =  buf) + fread(buf, 1, rlen, stdin)), ib == ob) ? -1 : *ib++)
inline int read() {
  static int ans, f;
  static char ch;
  ans = 0, ch = gc(), f = 1;
  while (!isdigit(ch)) f ^= ch == '-', ch = gc();
  while (isdigit(ch)) ans = (ans << 3) + (ans << 1) + (ch ^ 48), ch = gc();
  return f ? ans: -ans;
}
inline ll readl() {
  static ll ans;
  static char ch;
  for (ans = 0, ch = gc(); !isdigit(ch); ch = gc());
  while (isdigit(ch)) ans = ((ans << 2) + ans << 1) + (ch ^ 48), ch = gc();
  return ans;
}
inline int Read(char *s) {
  static int top;
  static char ch;
  top = 0, ch = gc();
  while (!isalpha(ch) && !isdigit(ch)) ch = gc();
  while (isalpha(ch) || isdigit(ch)) s[++top] = ch, ch = gc();
  return top;
}
namespace modular {
  const int mod = 1e9 + 7;
  //int mod;
  int ret;
  inline int add(int a, int b) { return a + b < mod ? a + b : a + b - mod; }
  inline int dec(int a, int b) { return a < b ? a - b + mod : a - b; }
  inline int mul(int a, int b) { return (ll) a * b % mod; }
  inline void Add(int &a, int b) { a = a + b < mod ? a + b : a + b - mod; }
  inline void Dec(int &a, int b) { a = a < b? a - b + mod : a - b; }
  inline void Mul(int &a, int b) { a = (ll) a * b % mod; }
  inline int ksm(int a, int p) {
    for (ret = 1; p; p >>= 1, Mul(a, a)) (p & 1) && (Mul(ret, a), 1);
    return ret;
  }
  inline int Inv(int a) { return ksm(a, mod - 2); }
  inline int sqr(int a) { return (ll) a * a % mod; }
  inline int cub(int a) { return (ll) a * a % mod * a % mod; }
} using namespace modular;
template <typename T> inline void ckmax(T &a, T b) { a < b ? a = b : 0; }
template <typename T> inline void ckmin(T &a, T b) { a > b ? a = b : 0; }
template <typename T> inline T Abs(T a) { return a < 0 ? -a : a; }
template <typename T> inline T gcd(T a, T b) {
  T t;
  while (b) t = a, a = b, b = t - t / a * a;
  return a;
}
template <typename T> inline void exgcd(T a, T b, T &x, T &y) {
  if (!b) {
    x = 1, y = 0;
    return;
  }
  exgcd(b, a - a / b * b, y, x);
  y -= a / b * x;
}
int main() {
  #ifdef ldxcaicai
  freopen("lx.in", "r", stdin);
  #endif
  int X = read();
  int g = X / gcd(X, 360);
  cout << g * 360 / X;
  return 0;
}

Measured memory_bytes: 3624