akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>


typedef long long ll;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBAC
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

ll lcm(ll a, ll b) {
	ll c;
	c = a * b / gcd(a, b);
	return c;
}

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const ll mod = 1000000007;
struct mint {
	ll x;
	mint(ll x = 0):x(x%mod){}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		res -= a;
	}
	mint operator*(const mint a)const {
		mint res(*this);
		return res *= a;
	}
};

map<string, int> memo;

using P=pair<int, int>;

struct Clock {
	int hour, minute, second;
	void set(int h, int m, int s) {
		hour = h; minute = m; second = s;
	}
	string to_str() {
		string h, m, s;
		h = to_string(hour);
		m= to_string(minute);
		s= to_string(second);
		if (h.size() < 2) h = "0" + h;
		if (m.size() < 2) m = "0" + m;
		if (s.size() < 2) s = "0" + s;
		return h + ":" + m + ":" + s;
	}
	void shift(int diff_second) {
		int h, m;
		h = diff_second / 3600;
		m = diff_second / 60;
		diff_second %= 60;
		second += diff_second;
		
	}
};


/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
int main() {
	int a, b;
	cin >> a >> b;
	if (a >= 13)cout << b;
	 else if (a >= 6)cout << b / 2;
	else cout << 0;
	return 0;
}










Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }


vector<int> dp;
vector<bool> visited, calculated;
int dfs(int v, vector<vector<int>> &to){
    if (visited[v]){
        if (!calculated[v]) return -1;
        else return dp[v];
    }
    visited[v] = true;
    dp[v] = 1;
    for(int d: to[v]){
        int res = dfs(d, to);
        if (res == -1) return -1;
        dp[v] = max(dp[v], res+1);
    }
    calculated[v] = true;
    return dp[v];
}

int main(){
    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int>(n-1));
    rep(i,n) rep(j,n-1){
        cin >> a[i][j];
        a[i][j]--;
    } 

    // 試合にIDを付与
    int v = 0;
    vector<vector<int>> gameId(n, vector<int>(n, -1));
    rep(i,n) rep(j,n){
        if (i < j){
            gameId[i][j] = v++;
        }
        else {
            gameId[i][j] = gameId[j][i];
        }
    }

    // 試合に辺を追加していく
    vector<vector<int>> to(v);
    rep(i,n) rep(j,n-2){
        int id1 = gameId[i][a[i][j]];
        int id2 = gameId[i][a[i][j+1]];
        to[id1].push_back(id2);
    }

    // 最長経路を求める
    dp.resize(v);
    visited.reserve(v);
    calculated.resize(v);
    int ans = 0;
    rep(i, v){
        int res = dfs(i, to);
        if (res == -1){
            cout << -1 << endl;
            return 0;
        }
        ans = max(ans, res);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 40672
//													\[T]/ Praise
//													 (*)  The
//													 / \  Sun



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

typedef long long ll;
typedef long double dbl;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<long long> vl;
typedef vector< pair<int, int> > vii;
#define mp make_pair
#define pb push_back
#define invec(a, n) for(ll i = 0; i < n; i++) {cin >> a[i];}
#define rep(n) for(ll i = 0; i < n; i++)
#define fr(i,j,k) for(ll i = j; i < k; i++)
#define FR(i,j,k) for(ll i = j; i >= 0; i--)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
#define INF 1000000
#define xx first
#define yy second

void fast()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

int main()
{

	string s, t;
	cin >> s >> t;

	int n, m;
	n = s.length();
	m = t.length();

	int dp[n+1][m+1];

	fr(i,0,n+1)
		dp[i][0] = 0;

	fr(i,0,m+1)
		dp[0][i] = 0;

	fr(i,1,n+1)
	{
		fr(j,1,m+1)
		{
			if(s[i-1] == t[j-1])
				dp[i][j] = max({dp[i-1][j-1] + 1, dp[i-1][j], dp[i][j-1]});
			else
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);

		}
	}

	// fr(i,0,n+1)
	// {
	// 	fr(j,0,m+1)
	// 	{
	// 		cout << dp[i][j] << "\t";
	// 	}
	// 	cout << "\n";
	// }

	string res = "";
	// cout << res << "\n";
	// return 0;
	int x = n, y = m;

	while(x != 0 && y != 0)
	{
		if(dp[x][y] == (dp[x-1][y-1] + 1) && s[x-1] == t[y-1])
		{
			res += s[x-1];
			x--; y--;
			continue;
		}

		if(dp[x][y] == dp[x-1][y])
		{
			x--;
			continue;
		}

		if(dp[x][y] == dp[x][y-1])
		{
			y--; continue;
		}
	}

	reverse(all(res));

	cout << res;
}

Measured memory_bytes: 35456
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
 
int main() {
	char a,b;
	cin >> a >> b;
	if (a==b) cout << 'H';
	else cout << 'D';
}

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

int main(){
int N,A,B;
  cin >> N >> A >>B;
int count_1,count_2,count_3,count_min;
  count_1=0;
  count_2=0;
  count_3=0;
  
  for(int i=0;i<N;i++){
      int X;
    cin >>X;
     if(X<A+1){
     count_1++;
     }
     else if(A<X && X<B+1){
     count_2++;
     }
     else if(B<X){
     count_3++;
     }
  }
  
  count_min=min(count_1,(min(count_2,count_3))); 
  cout<< count_min<<endl;
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/abc121/tasks/abc121_b

#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <bitset>


using namespace std;
int main(){
	int ab,bc,ca,answer;
	cin>>ab>>bc>>ca;

	vector<int> x(3);
	x.at(0)=ab;
	x.at(1)=bc;
	x.at(2)=ca;
	
	std::sort(x.begin(),x.end());
	answer=0.5*x.at(0)*x.at(1);
	cout<<answer<<endl;
}
	






Measured memory_bytes: 256
N = int(input())
S_list = []
min_length = 10000
for _ in range(N):
    st = input()
    S_list.append(st)
    min_length = min(min_length, len(st))
char_list = list("abcdefghijklmnopqrstuvwxyz")
total_counter = {char: 1e4 for char in char_list}
for i in range(N):
    string = S_list[i]
    for char in char_list:
        total_counter[char] = min(total_counter[char], string.count(char))


ans = ""

for char, count in total_counter.items():
    ans += char*count
    
print(ans)

Measured memory_bytes: 65784
#include <iostream>

using namespace std;

int main(void){
  int a,b,k;
  int ans = 0;
  cin >> a >> b >> k;
  if(a > b){
    for(int i = a;i > 0;i--){
      if(a%i == 0 && b%i == 0){
        k--;
        if(k == 0){
          ans = i;
          break;
        }
      }
    }
  }
  else if(a < b){
    for(int i = b;i > 0;i--){
      if(a%i == 0 && b%i == 0){
        k--;
        if(k == 0){
          ans = i;
          break;
        }
      }
    }
  }
  else{
    for(int i = a;i > 0;i--){
      if(a%i == 0 && b%i == 0){
        k--;
        if(k == 0){
          ans = i;
          break;
        }
      }
    }
  }
  cout << ans << "\n";
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		int n = sc.nextInt();

		for (int i = 1; i <= n; i++)
		{
			int temp = i;
			if (temp % 3 == 0)
			{
				System.out.print(" " + i);
				continue;
			}

			do
			{
				if (temp % 10 == 3)
				{
					System.out.print(" " + i);
					break;
				}
				else
				{
					temp /= 10;
				}
			} while (temp > 0);

		}

		System.out.println();
	}
}



Measured memory_bytes: 28652
def solve():
    s = input()
    bit = 0
    for i in range(len(s)):
        if bit == 0:
            if s[i] == "C":
                bit = 1
        if bit == 1:
            if s[i] == "F":
                bit = 2
                break
    if bit == 2:
        print("Yes")
    else:
        print("No")
    return 0

if __name__ == "__main__":
    solve()

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

int n;
int res = 100000;

int Dsum(int x)
{
	int res = 0;
	while (x) {
		res += x % 10;
		x /= 10;
	}
	return res;
}

int main()
{
	scanf("%d", &n);
	for (int i = 1; i < n; i++)
		res = min(res, Dsum(i) + Dsum(n - i));
	printf("%d\n", res);
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int64_t A;
  int64_t nans = 1;
  int64_t ans = 1;
  bool flag = false;
  for (int i = 0; i < N; i++){
    cin >> A;
    if (A == 0){
      nans = 0;
      break;
    }
    if (!flag){
      ans = nans;
      nans = ans * A;
    }
    if (nans > 1000000000000000000 || ans != nans / A){
      nans = -1;
      flag = true;
    }
  }
  cout << nans << endl;
}


Measured memory_bytes: 3636
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"
#include "stack"

#define rep(n) for (int i = 0; i < n; ++i)
#define REP(n,i) for (int i = 0; i < n; ++i)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define P pair<ll, ll>
typedef long long ll;
using namespace std;

int n, m, x, y, l, mx;
int main() {
	cin >> n >> m >> x >> y;
	mx = x;
	rep(n) {
		cin >> x;
		mx = max(mx, x);
	}
	if (mx >= y) {
		cout << "War" << endl;
		return 0;
	}
	rep(m) {
		cin >> y;
		if (y <= mx) {
			cout << "War" << endl;
			return 0;
		}
	}
	cout << "No War" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n, d, dsum, ans;
    dsum = 0;
    ans = 0;
    scanf("%d", &n);
    for (int i=0; i<n; i++) {
        scanf(" %d", &d);
        ans += d * dsum;
        dsum+=d;
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 128
import java.io.*;
 
class Main {
    public static void main(String[] args) {
        BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
        try {
          
            int n, x;
            int cnt, ave3, ave2;
            String[] tmpArray;  
            while( true ) {
                String str = kb.readLine();
                tmpArray = str.split( " " );
                n = Integer.parseInt( tmpArray[0] );
                x = Integer.parseInt( tmpArray[1] );
             
                if( 0 == n && 0 == x ) {  break; }
             
                cnt = 0;
                ave3 = x / 3;
                int i, j, k;
                for( i=1; i<ave3; i++ ) {
                    ave2 = ( x-i ) / 2;
                    for( j=i+1; j<=ave2; j++ ) {
                        k = x - i - j;
                        if( j < k && k <= n ) {
                            cnt++;
                        }
                    }
                }
                System.out.println( cnt );    
            }
        } catch( IOException e ) {
            System.err.println( e );
        }
    }
}

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

int main() {
	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int ans = 0;
	// cout << "--";
	for (int i = 0; i < n; i++) {
		for (int j = i + 1 ; j < n ; j++) {
			for (int k = j + 1 ; k < n; k++) {
				set<int> s;
				s.insert(a[i]);
				s.insert(a[j]);
				s.insert(a[k]);
				if (s.size() == 3) {
					vector<int> v;
					v.push_back(a[i]);
					v.push_back(a[j]);
					v.push_back(a[k]);
					sort(v.begin(), v.end());
					if (v[0] + v[1] > v[2]) {
						ans++;
					}
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <ctime>
#include <map>

#define inf 0x3f3f3f3f
#define Inf 0x3FFFFFFFFFFFFFFFLL
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Rep(i, n) for (int i = 1; i <= (n); ++i)
#define clr(x, a) memset(x, (a), sizeof x)
using namespace std;
typedef long long ll;
set<string>s;
int main() {
  int n;cin>>n;
  char lc=0;
  bool ok=1;
  rep(i,n){
    string a;cin>>a;
    if(lc != 0 && a[0] != lc) ok = 0;
    if(s.find(a)!=s.end()) ok = 0;
    s.insert(a);
    lc = a[a.length() - 1];
  }
  if (ok) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

class Procon {
    static void Main (string[] agrs) {
        int N = Int();
        int[] d = new int[N];
        for (int i = 0; i<N; i++) {
            d[i] = Int();
        }

        Array.Sort(d);

        int ans = 1;
        for (int i = 1; i<N; i++) {
            if (d[i] != d[i-1]) {
                ans ++;
            }
        }
        Console.WriteLine(ans);
    }

    static string String () => Scanner.nextString ();
    static int Int () => int.Parse (Scanner.nextString ());
    static long Long () => long.Parse (Scanner.nextString ());
    static double Double () => double.Parse (Scanner.nextString ());
    static char[] Chars () => String ().ToCharArray ();
    static string[] Strings () => Console.ReadLine ().Split (' ');
    static int[] Ints () => Strings ().Select (v => int.Parse (v)).ToArray ();
    static long[] Longs () => Strings ().Select (v => long.Parse (v)).ToArray ();
    static double[] Doubles () => Strings ().Select (v => double.Parse (v)).ToArray ();
    const int M = 1000000007;
    static void Dbg (object a) => Console.WriteLine (a);
    static void Dbg (params object[] a) => Console.WriteLine (string.Join (" ", a));
    static void Dbgs<T> (IEnumerable<T> a, string split = " ") => Console.WriteLine (string.Join (split, a));
    static T Max<T> (params T[] a) => a.Max ();
    static T Min<T> (params T[] a) => a.Min ();
}

class PriorityQueue<T> where T : IComparable<T> {
    public T[] heap;
    public int size;
    public int sign;
    public PriorityQueue (int N, bool descend = false) {
        heap = new T[N];
        if (descend) sign = -1;
    }
    public int Compare (T x, T y) {
        return x.CompareTo (y) * sign;
    }
    public void Push (T x) {
        int i = size++;
        while (i > 0) {
            int p = (i - 1) / 2;
            if (Compare (x, heap[p]) >= 0) {
                break;
            }
            heap[i] = heap[p];
            i = p;
        }
        heap[i] = x;
    }
    public T Pop () {
        T ret = heap[0];
        T x = heap[--size];
        int i = 0;
        while (i * 2 + 1 < size) {
            int a = i * 2 + 1;
            int b = i * 2 + 2;
            if (b < size && Compare (heap[a], heap[b]) > 0) {
                a = b;
            }
            if (Compare (heap[a], x) >= 0) {
                break;
            }
            heap[i] = heap[a];
            i = a;
        }
        heap[i] = x;
        return ret;
    }
    public int Count () {
        return size;
    }
}

class Scanner {
    static string[] s = new string[0];
    static int i = 0;
    static int max_i = 0;
    static public string nextString () {
        if (i >= s.Length) {
            s = Console.ReadLine ().Split (' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0) {
                return "";
            }
            return s[i++];
        }
        return s[i++];
    }
}

Measured memory_bytes: 13140
n = int(input())
a = list(map(int, input().split()))
ans_even = 0
ans_odd = 0
sum = 0
# 偶数番目を正にする
for i in range(n):
    # 和を正にする
    if i % 2 == 1:
        sum += a[i]
        if sum > 0:
            pass
        else:
            ans_even += 1 - sum
            sum = 1
    # 和を負にする
    else:
        sum += a[i]
        if sum < 0:
            pass
        else:
            ans_even += abs(-1 - sum)
            sum = -1
# 奇数番目を正にする
sum = 0
for i in range(n):
    # 和を正にする
    if i % 2 == 0:
        sum += a[i]
        if sum > 0:
            pass
        else:
            ans_odd += 1 - sum
            sum = 1
    # 和を負にする
    else:
        sum += a[i]
        if sum < 0:
            pass
        else:
            ans_odd += abs(-1 - sum)
            sum = -1
print(min(ans_even, ans_odd))

Measured memory_bytes: 14648
N=int(input())
x,y,h=[],[],[]
for i in range(0,N):
  x1,y1,h1=map(int,input().split())
  x.append(x1)
  y.append(y1)
  h.append(h1)
for cx in range(0,101):
  for cy in range(0,101):
    ans=1
    m=0
    for i in range(0,N):
      if(h[i]!=0):
        m=abs(x[i]-cx)+abs(y[i]-cy)+h[i]
        break
    for j in range(0,N):
      if(max(m-abs(x[j]-cx)-abs(y[j]-cy),0)!=h[j]):
        ans=0
    if(ans):
      print(cx,cy,m)
      break

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int N = 100010, mod = 1000000007;
char s[N];
int g[N], f[N], n, sum[N];

int main() {
  scanf("%s", s + 1);
  n = (int)strlen(s + 1);
  g[n + 1] = n + 1;
  sum[n + 1] = 0;
  for (int i = n; i; i--) {
    g[i] = s[i] == s[i + 1] ? i + 1 : g[i + 1];
    sum[i] = (sum[i + 1] + s[i] - 'a' + 1) % 3;
  }
  if (g[1] == n + 1) {
    puts("1");
    return 0;
  }
  f[0] = 1;
  int ans = 0;
  for (int i = 0; i <= n; i++) {
    if (i && sum[i + 1] == 0) {
      ans = (ans + f[i]) % mod;
    }
    f[i + 1] = (f[i + 1] + f[i]) % mod;
    f[g[i + 1]] = (f[g[i + 1]] + f[i]) % mod;
  }
  printf("%d\n", ans);
  return 0;
}



Measured memory_bytes: 1536
TaHP,TaAP,AoHP,AoAP = map(int, input().split())

Flag_Ta = True
Flag_end = True
while Flag_end:
	if(TaHP <= 0 or AoHP <= 0):
  		break
	if	Flag_Ta:
		AoHP = AoHP - TaAP
		Flag_Ta = False
	else:
		TaHP = TaHP - AoAP
		Flag_Ta = True
if TaHP > 0:
	print("Yes")
else:
	print("No")
	
	

Measured memory_bytes: 9080
#include <iostream>
#include <vector>
#include <deque>
#include <tuple>
#include <algorithm>
#include <iterator> // std::back_inserter

using namespace std;

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

    int max = 0;
    int seq = 0;
    char prev = 0;
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] == 'R')
        {
            seq++;
            if (seq > max)
            {
                max = seq;
            }
        }
        else
        {
            seq = 0;
        }
        prev = s[i];
    }

    cout << max << endl;
}


Measured memory_bytes: 3568
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<bitset>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
int N;
bool leading[27];
map<char,ll> coefficient;
map<P,int> cntbox;//first -> sum,second -> bit
map<ll,set<int> > cntbex;
int ans;
int S;

ll my_pow(ll a,ll e)
{
  return !e?1:
    (e%2?a*my_pow(a,e-1):my_pow(a*a,e/2));
}

ll getSum(vector<int>& toInt,vector<char>& alpha)
{
  ll sum = 0;
  for(int i=0;i<alpha.size();i++)
    sum += toInt[i]*coefficient[alpha[i]];   
  return sum;
}

void dfs(vector<int>& toInt,vector<char>& alpha,int pos,int used,bool flag)
{

  if(pos >= toInt.size() && !flag)
    {
      ll sum = getSum(toInt,alpha);      
      cntbox[P(sum,used)]++; 
      cntbex[sum].insert(used);
      return;
    }
  else if(pos >= toInt.size() && flag)
    {
      ll sum = getSum(toInt,alpha);
     
      sum = -sum;
 
      set<int> dex = cntbex[sum];
      for(set<int>::iterator it = dex.begin();it != dex.end();it++)
	{
	  int it_bit = (*it);
	  bool ok = true;
	  for(int j=0;j<10;j++)
	    {
	      if(((it_bit >> j) & 1) && ((used >> j) & 1))
		{
		  ok = false;
		  break;
		}
	    }
	  if(ok)
	    ans += cntbox[P(sum,it_bit)]; 	    
	}
      return;
    }

  for(int i=0;i<10;i++)
    {
      if(!i && leading[alpha[pos]-'A'])
	continue;
      if((used>>i) & 1)
	continue;
      toInt[pos] = i;
      dfs(toInt,alpha,pos+1,used|(1<<i),flag);
    }

}

int main()
{
  while(cin >> N,N)
    {//半分全列挙
      ans = 0;
      coefficient.clear();
      cntbox.clear();
      cntbex.clear();
      vector<string> vec(N);
      set<char> al;
      int mex,mex2;
      mex = mex2 = 0;
      rep(i,27)leading[i] = false;
      rep(i,N)
	{
	  cin >> vec[i];
	  if(i != N-1)
	    mex = max(mex,(int)vec[i].size());
	  else
	    mex2 = max(mex2,(int)vec[i].size());
	  if(vec[i].size() != 1)
	    leading[vec[i][0]-'A'] = true;
	  if(i != N-1)
	    rep(j,vec[i].size())
	      coefficient[vec[i][j]] += my_pow(10,vec[i].size()-1-j),al.insert(vec[i][j]);  
	  else
	    rep(j,vec[i].size())
	      coefficient[vec[i][j]] -= my_pow(10,vec[i].size()-1-j),al.insert(vec[i][j]);   
	}

      if(mex2 < mex || abs(mex2-mex) >= 3)
	{
	  cout << 0 << endl;
	  continue;
	}    

      int cn,sz;
      sz = S = al.size();
      cn = 0;
      vector<char> A,B;
      for(set<char>::iterator it = al.begin();it != al.end();it++)
	{
	  if(cn < sz/2)
	    A.push_back((*it));
	  else
	    B.push_back((*it));
	  cn++;
	}
      
      vector<int> toInt(A.size());
      dfs(toInt,A,0,0,false);
      toInt.resize(B.size());
      dfs(toInt,B,0,0,true);
      cout << ans << endl;
    }
  return 0;
}

Measured memory_bytes: 9420
import java.util.Scanner;
 
class Main {
        public static void main(String args[]) {
                Scanner sc = new Scanner(System.in);
                int N = sc.nextInt();
                int data[][] = new int[N][3];
                for (int i = 0; i < N; i++) {
                        for (int j = 0; j < 3; j++) {
                                data[i][j] = sc.nextInt();
                        }
                }
                for (int i = 0; i < N; i++) {
                        int ans = 0;
                        for (int j = 0; j < 3; j++) {
                                boolean f = true;
                                for (int k = 0; k < N; k++) {
                                        if (i != k) {
                                                if (data[i][j] == data[k][j]) {
                                                        f = false;
                                                        break;
                                                }
                                        }
                                }
                                if (f) {
                                        ans += data[i][j];
                                }
                        }
                        System.out.println(ans);
                }
        }
}


Measured memory_bytes: 29316
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int N;
      cin >> N;
      
      string ans = "APPROVED";
      for (int i = 0, j; i < N; i++) {
        cin >> j;
        if (j % 2 == 0 && j % 3 != 0 && j % 5 != 0) {
          ans = "DENIED";
        }
      }
      
      cout << ans << endl;
    }

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

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

using namespace std;
const long long INF = 1LL << 61;

int main() {
	int A, B; cin >> A >> B;
	if ((A + B) % 2 == 0)cout << (A + B) / 2;
	else if (A == B)cout << 0;
	else cout << "IMPOSSIBLE";
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  char a[3][3];
  for(int  i=0;i<3;i++){
    for(int j=0;j<3;j++){
       cin >> a[i][j];
    }
  }
  for(int i=0;i<3;i++){
    cout << a[i][i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int a,b;
    int i;
    int total;
    scanf("%d%d",&a,&b);
    if(a==b){
        total=a+b;
    }else if(a>b){
        total=a+a-1;
    }else{
        total=b+b-1;
    }
    printf("%d\n",total);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(){
    int i = 0, j;
    int nm[10000];
    
    scanf("%d", &nm[i]);
    while(nm[i] != 0){
        i++;
        scanf("%d", &nm[i]);
    }


    for(j = 0; j < i; j++){
        printf("Case %d: %d\n", j+1, nm[j]);
    }
    
    return 0;
}


Measured memory_bytes: 1992
#include <bits/stdc++.h>
const int INF = 1e9;
const int MODk = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int A,P;cin >> A>> P;
    P += A*3;
    cout<<P/2<<endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
#define int long

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

template <class T> void vecout(T V) {
    auto t = V.begin();
    while(t != V.end()) {
        cout << *t++;
        if(t != V.end()) cout << " ";
    }
    cout << endl;
};

template <typename T> T gcd(T a, T b) {
    if(a > b) gcd(b, a);
    T r;
    while(r = a % b) {
        a = b;
        b = r;
    }
    return b;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, c, k;
    cin >> n >> c >> k;
    vector<int> A(n);
    rep(i, n) cin >> A[i];
    sort(all(A));
    int r = 0, f = -INFINT, b = 0;
    for(auto e : A) {
        if(e - f > k || r == c) {
            r = 1;
            f = e;
            b++;
        } else {
            r++;
        }
    }
    cout << b << endl;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
	
}

signed main(){
	ll a,b;
	cin >> a >> b;
	if(a >= 10 || b >= 10) cout << -1 << endl;
	else cout << a*b << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<ll,ll> P;
const ll MOD=10000;
const ll INF=1000000010;
const ll LINF=1000000000000000010;
const int MAX=100001;
int dx[8]={0,1,0,-1,1,-1,1,-1};
int dy[8]={1,0,-1,0,1,-1,-1,1};
ll keta(ll n){
    int d=0;
    while(n>0){
        n/=10;
        d++;
    }
    return d;
}
int main(){
    int n;
    while(cin>>n,n){
        int a[12][12]={};
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                cin>>a[i][j];
                a[i][n]+=a[i][j];
            }
        }
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                a[n][i]+=a[j][i];
            }
        }
        for(int i=0;i<n;i++){
            a[n][n]+=a[n][i];
        }
        for(int i=0;i<=n;i++,cout<<endl){
            for(int j=0;j<=n;j++){
                printf("%5d",a[i][j]);
            }
        }
    }
	return 0;
}



Measured memory_bytes: 3120
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
  		int[] a=new int[9];
		for(int c=0;c<n;c++){
    		int b=sc.nextInt();
          if(b<3200){
            a[b/400]++;
          }else{
          	a[8]++;
          }
    	}
        int ans=0;
  		for(int d=0;d<8;d++){
        	if(a[d]>0){
            ans++;
            }
        }
        System.out.println(Math.max(ans,1));
     	System.out.println(ans+a[8]);
    }
}


Measured memory_bytes: 35944
#include<bits/stdc++.h>
using namespace std ;
#define Next( i, x ) for( register int i = head[x]; i; i = e[i].next )
#define rep( i, s, t ) for( register int i = s; i <= t; ++ i )
#define re register
int gi() {
	char cc = getchar() ; int cn = 0, flus = 1 ;
	while( cc < '0' || cc > '9' ) {  if( cc == '-' ) flus = - flus ; cc = getchar() ; }
	while( cc >= '0' && cc <= '9' )  cn = cn * 10 + cc - '0', cc = getchar() ;
	return cn * flus ;
}
const int M = 1e5 + 5 ; 
struct E {
	int to, next, w ;
} e[M * 20] ; 
int n, m, cnt, head[M], dis[M], vis[M] ; 
void add( int x, int y, int z ) {
	e[++ cnt] = (E){ y, head[x], z }, head[x] = cnt ; 
}
queue<int> q ;
void spfa() {
	memset( dis, 63, sizeof(dis) ) ;
	rep( i, 1, 9 ) {
		dis[i % n] = min( dis[i % n], i ) ;
		if( !vis[i % n] ) q.push(i % n), vis[i % n] = 1 ;
	}
	while( !q.empty() ) {
		int u = q.front() ; q.pop(), vis[u] = 0 ;
		Next( i, u ) {
			int v = e[i].to ; 
			if( dis[v] > dis[u] + e[i].w ) {
				dis[v] = dis[u] + e[i].w ;
				if( !vis[v] ) q.push(v), vis[v] = 1 ;
			}
		}
	}
	printf("%d\n", dis[0] ) ;
}
signed main()
{
	n = gi() ; 
	rep( i, 0, n - 1 ) rep( j, 0, 9 )
	add( i, ( i * 10 + j ) % n, j ) ;
	spfa() ; 
	return 0 ;
}


Measured memory_bytes: 14976
N = int(input())
AB =[]
V = [[] for _ in range(N)]
Edict = dict()
for _ in range(N-1):
    a,b = map(int,input().split())
    AB.append((a-1,b-1))
    V[a-1].append(b-1)
    V[b-1].append(a-1)
K = max(len(V[i]) for i in range(N))
for i in V:
    i.sort()
for i,v in enumerate(V[0]):
    Edict[(0,v)] = i
for i in range(1,N): # 2(N-1)
    color = 0
    for j in V[i]:
        if j < i: # unique per V and first
            parent_color = Edict[(j,i)]
        else:
            if color == parent_color:
                color += 1
            Edict[(i,j)] = color
            color += 1
print(K)
for i in AB:
    print(Edict[i]+1)

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

main(){
  int a,b,c,d,e,f,g,h;
  cin>>a>>b;
  c=a+b;
  d=a-b;
  e=a*b;
  f=max(c,d);
  g=max(d,e);
  h=max(f,g);
  cout<<h<<endl;
}

Measured memory_bytes: 3608
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

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

  long long ans = (1LL << 60);
  long long snuke = 0;
  long long kuma = sum;
  for (int i = 0; i < n - 1; i++) {
    snuke += a[i];
    kuma -= a[i];
    ans = min(ans, abs(snuke - kuma));
  }
  cout << ans << endl;

  return 0;
}

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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int n, k = 0;
	cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
		if (v[i] != i + 1) k++;
	}

	if (k == 0 || k == 2) {
		cout << "YES" << "\n";
	}else { 
		cout << "NO" << "\n"; 
	}
	return 0;
}


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

int main()
{
    int N, L;
    cin >> N >> L;
    vector<string> str(N);
    for(int i = 0; i < N; i++) cin >> str[i];
    sort(str.begin(),str.end());
    for(int i = 0; i < N; i++) cout << str[i];
    cout << endl;
}

Measured memory_bytes: 256
n = int(input())
S,T = set(),set()
a = [int(i) for i in input().split()]
for i in range(n):
    S.add(a[i])
n = int(input())
a = [int(i) for i in input().split()]
for i in range(n):
    T.add(a[i])
print(len(S&T))

"""
5
1 2 3 4 5
3
3 4 1
"""


Measured memory_bytes: 17796
import sys
# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))

# ===CODE===

eps = 10 ** (-9)


def main():
    n = ni()
    a = na()

    a.sort(reverse=True)

    ans = 0
    for i in range(1, n):
        ans += a[i//2]

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 33388
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;
int main(){
	int a ,b, n;
	cin>> n;

	a = 4;
	b = 7;

	string ans = "No";

	for(int i = 0;i<25;i++){
		for(int j = 0;j<25;j++){
			int sum = 4*i + 7*j;
			if(sum == n)
				ans = "Yes";
		}
	}
	cout<< ans <<endl;
}



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

int h[100000];
int c[100000];

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

  c[n-1] = 0;
  for (int i = n - 2; i >= 0; i--) {
    c[i] = INT_MAX;
    for (int j = i + 1; j <= i + k && j < n; j++) {
      c[i] = min(c[i], c[j]+abs(h[i]-h[j]));
    }
  }

  cout << c[0];

  return 0;
}

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

int main() {
 string s; cin >> s;
  if(s == "SUN") cout << "7\n";
  else if(s == "SAT") cout << "1\n";
  else if(s == "MON") cout << "6\n";
  else if(s == "TUE") cout << "5\n";
  else if(s == "WED") cout << "4\n";
  else if(s == "THU") cout << "3\n";
  else cout << "2\n";
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int main(void){
    char str[10];
    for(int i=0;i<10;i++)scanf("%c", &str[i]);
    char *ptr;

    int a = strtol(strtok(str,"/"),NULL,10);
    int b = strtol(strtok(NULL,"/"),NULL,10);
    int c = strtol(strtok(NULL,"/"),NULL,10);
    if(a < 2019){
        printf("Heisei");
    }else if(a == 2019){
        if(b < 4){
            printf("Heisei");
        }else if(b == 4){
            if(c <= 30){
                printf("Heisei");
            }else{
                printf("TBD");
            }
        }else{
            printf("TBD");
        }
    }else{
        printf("TBD");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
typedef long long int ll;

int h,w;
char s[420][420];
bool used[420][420];

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

ll cnt,cnt1;

void dfs(int x,int y){
	if(used[x][y])return ;
	used[x][y]=true;
	if(s[x][y]=='.')cnt++;
	else cnt1++;
	for(int i=0;i<4;i++){
		int nx=x+dx[i],ny=y+dy[i];
		if(nx<0||ny<0||nx>=h||ny>=w) continue;
		if(s[x][y]==s[nx][ny])continue;
		dfs(nx,ny);
	}
}

int main(){
	cin >> h >> w;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin >> s[i][j];
		}
	}
	ll ans=0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(used[i][j])continue;
			cnt=cnt1=0;
			dfs(i,j);
			ans+=cnt*cnt1;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

ll n, t = 0;
vector<vector<ll>> g;
vector<ll> d, f;

void dfs(ll v, ll p = -1) {
    if (d[v] != -1) return;
    t++;
    d[v] = t;
    rep(i, sz(g[v])) {
        if (g[v][i] == p) continue;
        dfs(g[v][i], v);
    }
    f[v] = t;
    t++;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    cin >> n;
    g.resize(n);
    rep(i, n) {
        ll u, k;
        cin >> u >> k;
        u--;
        rep(j, k) {
            ll v;
            cin >> v;
            v--;
            g[u].push_back(v);
        }
    }
    rep(i, n) sort(all(g[i]));
    d.resize(n, -1);
    f.resize(n, -1);
    rep(i, n) {
        if (d[i] == -1) dfs(i);
    }
    rep(i, n) {
        printf("%lld %lld %lld\n", i + 1, d[i], f[i] + 1);
    }
    return 0;
}



Measured memory_bytes: 3296
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n);i++)
#define rep1(i,n) for(int i=1; i<(n); i++)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
const int INF = 1e9;
const LL LLINF = 1e16;
const int mod = 1e9+7;

int main(){
    vector<int> a(5);
    rep(i, 5) cin >> a[i];
    int tmp = -1, tmp2 = 10;
    rep(i, 5)if(a[i]%10 > 0 && tmp2 > a[i]%10){
        tmp = a[i];
        tmp2 = a[i] %10;
    }
    int ans = 0;
    rep(i, 5){
        ans += a[i] + (10-a[i]%10)%10;
    }
    if(tmp != -1) ans += tmp2 - 10;
    cout << ans << endl;

}

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *CSF = map(int, read().split())
    train = [0] * (N - 1)
    for i, t in enumerate(zip(*[iter(CSF)] * 3)):
        train[i] = t

    ans = [0] * N
    for i in range(N - 1):
        t = 0
        for c, s, f in train[i:]:
            if t < s:
                t = s + c
            else:
                t += f - ((t - 1) % f + 1) + c
        ans[i] = t

    ans[N - 1] = 0
    print(*ans, sep='\n')
    return


if __name__ == '__main__':
    main()


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

int main(){
  char b;
  cin >> b;
  if(b == 'A') cout << 'T' << endl;
  else if(b == 'T') cout << 'A' << endl;
  else if(b == 'C') cout << 'G' << endl;
  else cout << 'C' <<endl;
  return 0;
}



Measured memory_bytes: 256
object Main{
  def main(args: Array[String]){
    val input=io.Source.stdin.getLines().mkString("\n")
    println(solve(input).trim())
  }

  def solve(input:String):String={
    val nkq = input.split("\n")(0).split(" ")
    val n = nkq(0).toInt
    val k = nkq(1).toInt
    val q = nkq(2).toInt
    val as = input.split("\n").tail.map(_.toInt)
    val cnt_mp = as.groupBy(v=>v)
    Range(1,n+1).toList.map(v => if(k-q+cnt_mp.getOrElse(v,Array[Int]()).size>0) "Yes" else "No").mkString("\n")
  }
}


Measured memory_bytes: 86588
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

ll N;
void input(){
    fast_io();
    cin >> N;
}

vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int solve(){
    auto D = divisor(N);
    ll ans = 0;
    for(auto d:D){
        ll m = d-1;
        if(m==0) continue;
        if((N/m)==N%m) ans += m;
    }
    cout << ans << endl;
    return 0;
}   

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

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

 int main (){ 
     string s;
     cin >> s;
     if(s== "Sunny")
     { cout << "Cloudy";}
     
     if(s== "Cloudy")
     { cout << "Rainy";}
     
     if (s== "Rainy")
     { cout << "Sunny";}
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
using namespace std;
int main() {
    int i, a, b, k, t;
    int c=0;
    cin >> a >> b >> k;
    for (i=min(a, b);i>=1;i--) {
        if ((a % i == 0) && (b % i == 0)) {
            c += 1;
        }
        if (c == k) {
            cout << i << endl;
            return 0;
        }
    }
}

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

int main(){
    int k;
    char s[1000];
    scanf("%d", &k);
    scanf("%s", s);
    int len = strlen(s);
    if(len > k){
        for(int i=0;i<k;i++) printf("%c", s[i]);
        printf("...");
    }
    else printf("%s", s);
    return 0;
}

Measured memory_bytes: 1732
#include<iostream>
#include<deque>
#include<map>
using namespace std;

typedef pair<int,int> Pair;
typedef map<int,bool> Map;
Map imap;

void work(void)
{
	int k=0;
	cin>>k;
	deque<Pair>deq;
	deq.push_back(make_pair(1,1));
	while(!deq.empty())
	{
		Pair x=deq.front();
		deq.pop_front();
		if(imap[x.first])
			continue;
		imap[x.first]=true;
		if(x.first==0)
		{
			cout<<x.second<<endl;
			break;
		}
		deq.push_front(make_pair((x.first*10)%k,x.second));
		deq.push_back(make_pair((x.first+1)%k,x.second+1));
	}
	return;
}

int main(int argc,char *argv[])
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL); 
	work();
	return 0;
}

Measured memory_bytes: 5760
def count_up(d, cut):
    ARC = len([1 for i in d if i >= cut])
    ABC = len(d) - ARC
    if ABC == ARC:
        return True
    return False

N = int(input())
d = list(map(int, input().split()))
d.sort()
print(d[N//2] - d[N//2 - 1])

Measured memory_bytes: 52780
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;

struct SegmentTree2 {
    private:
    int n;
    vector<int> node;

    public:
    // 元配列 v をセグメント木で表現する
    SegmentTree2(vector<int> v) {
        // 最下段のノード数は元配列のサイズ以上になる最小の 2 冪 -> これを n とおく
        // セグメント木全体で必要なノード数は 2n-1 個である
        int sz = v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1, 0);

        // 最下段に値を入れたあとに、下の段から順番に値を入れる
        // 値を入れるには、自分の子の 2 値を参照すれば良い
        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = max(node[2*i+1], node[2*i+2]);
    }

    int getmax(int a, int b, int k=0, int l=0, int r=-1) {
    // 最初に呼び出されたときの対象区間は [0, n)
    if(r < 0) r = n;

    // 要求区間と対象区間が交わらない -> 適当に返す
    if(r <= a || b <= l) return 0;

    // 要求区間が対象区間を完全に被覆 -> 対象区間を答えの計算に使う
    if(a <= l && r <= b) return node[k];

    // 要求区間が対象区間の一部を被覆 -> 子について探索を行う
    // 左側の子を vl ・ 右側の子を vr としている
    // 新しい対象区間は、現在の対象区間を半分に割ったもの
    int vl = getmax(a, b, 2*k+1, l, (l+r)/2);
    int vr = getmax(a, b, 2*k+2, (l+r)/2, r);
    return max(vl, vr);
    }
};

int main(){
    ll N, T; cin >> N >> T;
    vi a(N);
    rep(i, 0, N){
        cin >> a[i];
    }
    SegmentTree2 seg(a);
    ll maxi = 0;
    ll num = 0;
    rep(i, 0, N-1){
        ll mi = a[i];
        ll ma = seg.getmax(i+1, N);
        if(ma - mi > maxi){maxi = ma - mi; num = 1;}
        else if(ma - mi == maxi){num++;}
        else{continue;}
    }
    prtl(num);
}

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

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl

using namespace std;
using i64 = long long;

int main()
{
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<int> p(A), q(B), r(C);
    for (auto &&item : p)
    {
        cin >> item;
    }
    for (auto &&item : q)
    {
        cin >> item;
    }
    for (auto &&item : r)
    {
        cin >> item;
    }

    sort(p.begin(), p.end(), greater<int>());
    sort(q.begin(), q.end(), greater<int>());
    sort(r.begin(), r.end(), greater<int>());

    vector<int> s;
    for (int i = 0; i < X; i++)
    {
        s.push_back(p[i]);
    }
    for (int i = 0; i < Y; i++)
    {
        s.push_back(q[i]);
    }
    for (int i = 0; i < C; i++)
    {
        s.push_back(r[i]);
    }

    sort(s.begin(), s.end(), greater<int>());

    i64 deliciousness = 0;

    for (int i = 0; i < X + Y; i++)
    {
        deliciousness += s[i];
    }

    cout << deliciousness << endl;

    return 0;
}

Measured memory_bytes: 3572
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a =sc.nextInt();
		int b =sc.nextInt();
		int x =sc.nextInt();
		
		//溢れる瞬間には、水は底辺b,高さ1以下の直角三角形を底面とする高さaの三角柱
		//この体積が、a*a*b
		
		double ans=0;
		double tmp=0;
		
		//体積が、a*a*b/2いかのとき、
		if(x<=(a*a*b/2)) {
			tmp=((double)2*x)/(a*b*b);
			ans = 90.0 - Math.atan(tmp)*180.0/Math.PI;//度数に直す
			
		}else {
			//倒した時に三角形ができない。台形になる場合
			tmp=((double)2*(a*a*b-x))/(a*a*a);
			ans = Math.atan(tmp)*180.0/Math.PI;//度数に直す
		}
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 23636