akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <random>
#include <functional>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

ll min(ll a, ll b) {return a < b ? a : b;}
ll min(int a, ll b) {return a < b ? a : b;}
ll min(ll a, int b) {return a < b ? a : b;}
ll min(int a, int b) {return a < b ? a : b;}

ll max(ll a, ll b) {return a > b ? a : b;}
ll max(int a, ll b) {return a > b ? a : b;}
ll max(ll a, int b) {return a > b ? a : b;}
ll max(int a, int b) {return a > b ? a : b;}

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()
#define int long long

const int N = 510200;

int n;
string s;
vector<int> v;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    cin >> s;
  
    int multiply = 2;
    for (int i = 0; i + 1 < n; i++)
    {
        v.push_back(abs(s[i] - s[i + 1]));
    }

    for (int i = 0; i < v.size(); i++)
    {
        if (v[i] == 1) multiply = 1;
    }
    if (multiply == 2)
    {
        for (int i = 0; i < v.size(); i++)
        {
            v[i] /= 2;
        }
    }

    int res = 0;
    for (int i = 0; i < v.size(); i++)
    {
        if (v[i] == 1)
        {
            int t = (i & (v.size() - i - 1));
            if (t == 0) res ^= 1;
        }
    }
    cout << res * multiply << "\n";
}


Measured memory_bytes: 12436
import java.util.*;
import java.math.*;
import java.io.*;

public class Main{
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] arr= new int[n];
		for(int qq=1; qq<n; qq++){
			arr[qq] = in.nextInt();
		}
		HashMap<Integer, Integer> mp = new HashMap<>();
		for(int i=0; i<n; i++){
			mp.put(arr[i]-1, 1+mp.getOrDefault(arr[i]-1, 0));
		}
		for(int i=0; i<n; i++){
			System.out.println(mp.getOrDefault(i, 0));
		}
	}
}

Measured memory_bytes: 73664
from math import log2

N = int(input())
A = [int(i) for i in input().split()]

def solve() :
  m, M = A[-1], A[-1]
  max1 = [0] * (N + 1)
  max1[-1] = M
  for i in range(N - 1, -1, -1) :
    m = (m + 1) // 2 + A[i]
    M = M + A[i]
    max1[i] = M
  if not m <= 1 <= M :
    return -1
  
  ne = 1 - A[0]
  max2 = [0] * (N + 1)
  max2[0] = 1
  for i in range(1, N + 1) :
    ne = ne * 2 - A[i]
    max2[i] = ne + A[i]
    
  return sum(min(max1[i], max2[i])for i in range(N + 1))
  
print(solve())


Measured memory_bytes: 702328
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <cstring>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rep(i,n) for(int i=0;i<(int)n;i++)

typedef long long ll;
typedef complex<double> point;
typedef pair<int,int> pii;

// →↑←↓
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};

const double EPS = 1e-9;

struct ufo{
    point c;
    double r,v;
    bool alive;
};

//when goal return true;
bool go(ufo &u,int R){
    if(not u.alive) return false;
    if(abs(u.c) < R + u.v + EPS){
        u.c = 0;
        u.alive = false;
        return true;
    }else{
        u.c -= u.v * (u.c / (abs(u.c)));
        return false;
    }
}

double cross(point a,point b){
    return imag(conj(a)*b);
}

double dot(point a,point b){
    return real(conj(a)*b);
}
// 直線と点との距離
double dist_line_and_point(point a1,point a2,point b){
    return abs(cross(a2-a1,b-a1)) / abs(a2-a1);
}

// 線分と点との距離
double dist_linesegment_and_point(point a1,point a2,point b){
    if(dot(a2-a1,b-a1) < EPS) return abs(b-a1);
    if(dot(a1-a2,b-a2) < EPS) return abs(b-a2);
    return dist_line_and_point(a1,a2,b);
}

// 円と線分の交差判定
bool is_cross_linesegment_and_circle(point c,double r,point a1,point a2){
    return (dist_linesegment_and_point(a1,a2,c) < r+EPS and
             (r < abs(c-a1) + EPS or r < abs(c-a2) + EPS));
}

int main(){
    while(true){
        double R;
        int N;
        cin >> R >> N;
        if(abs(R) < EPS and N == 0) break;
        vector<ufo> us(N);

        for(int i=0;i<N;i++){
            cin >> us[i].c.real() >> us[i].c.imag() >> us[i].r >> us[i].v;
            us[i].alive = true;
        }

        int cnt = 0;
        while(true){
            int ac = 0;
            for(int i=0;i<N;i++){
                if(go(us[i],R)){
                    cnt++;
                }
                if(us[i].alive) ac++;
            }
            if(ac == 0) break;

            int nearest = 0;
            double mindist = 1e10;
            for(int i=0;i<N;i++){
                if(not us[i].alive) continue;
                if(mindist + EPS > abs(us[i].c)){
                    mindist = abs(us[i].c);
                    nearest = i;
                }
            }
            for(int i=0;i<N;i++){
                if(not us[i].alive) continue;
                if(is_cross_linesegment_and_circle(us[i].c,us[i].r,
                   us[nearest].c*point(1e10,0),us[nearest].c/abs(us[nearest].c)*R)){
                    us[i].alive = false;
                }
            }
        }
        cout << cnt << endl;

    }
    return 0;
}

Measured memory_bytes: 1260
using System;
using System.Linq;
using System.Collections.Generic;
class c
{
    static void Main()
    {
        var abk = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int k = abk[2];
        var list = new List<int>();
        for (int i = 1; i <= Math.Min(abk[0], abk[1]); i++)
        {
            if (abk[0] % i == 0 && abk[1] % i == 0) list.Add(i);
        }
        Console.WriteLine(list[list.Count() - k]);
    }
}


Measured memory_bytes: 11220
N = int(input())
src = list(map(int,input().split()))

cands = list(sorted(set(src)))

def enough(i):
    bit = [0] * (2*N+10)
    def bit_add(a,w):
        x = a
        while x <= (2*N+9):
            bit[x] += w
            x += (x & -x)
    def bit_sum(a):
        x = a
        ret = 0
        while x > 0:
            ret += bit[x]
            x -= (x & -x)
        return ret

    cums = [0]
    for a in src:
        tmp = 1 if a >= cands[i] else -1
        cums.append(cums[-1] + tmp)

    cnt = 0
    for i in range(N+1):
        a = cums[i] + N+5
        cnt += bit_sum(a)
        bit_add(a, 1)
    return cnt*2 >= N*(N+1)//2

ok = 0
ng = len(cands)
while ng - ok > 1:
    m = (ok+ng)//2
    if enough(m):
        ok = m
    else:
        ng = m
print(cands[ok])

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

#define MOD 1000000007

int main(int, char**)
{
    int n, k;
    cin >> n >> k;

    ll sum = 0;
    for (ll i = k; i <= n+1; i++) {
        sum = (sum + (i * (n-i+1) % MOD) + 1) % MOD;
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3620
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let N: usize = read();
    for _ in 0..N {
        let a: usize = read();
        if a % 2 == 0 {
            if a % 3 != 0 && a % 5 != 0 {
                println!("DENIED");
                return;
            }
        }
    }
    println!("APPROVED");
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 200000
#define LL long long
int stk[MAXN+5];
int n,top;
LL a[MAXN+5],d[MAXN+5],ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		while(a[stk[top]]>=a[i])top--;
		d[i]=stk[top];stk[++top]=i;
	}
	top=0,stk[0]=n+1;
	for(int i=n;i>=1;i--)
	{
		while(a[stk[top]]>=a[i])top--;
		ans+=a[i]*(i-d[i])*(stk[top]-i);stk[++top]=i;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 4096
import java.util.Scanner;

public class Main {

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

		// input
		final int NUM = scan.nextInt();
		int[] nums = new int[NUM];
		int first = Integer.MIN_VALUE;
		int second = Integer.MIN_VALUE;
		for(int i = 0; i < NUM; i++){
			nums[i] = scan.nextInt();
			if(nums[i] > first && first == second){
				first = nums[i];
			} else if (nums[i] > first){
				first = nums[i];
			} else if (nums[i] > second){
				second = nums[i];
			}
		}

		// answer
		for(int i = 0; i < NUM; i++){
			if(nums[i] == first){
				System.out.println(second);
			} else {
				System.out.println(first);
			}
		}

	}
}


Measured memory_bytes: 115268
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,k = 0;
    cin >> a >> b >> c;
    
    for(int x = a; x <= b; x++){
        if(c % x == 0) k++;
    }
    cout << k << endl;
    return 0;
}



Measured memory_bytes: 3104
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define EPS 1e-10
using namespace std;
typedef long long llong;
int main() {
	for (int i = 0; i < 7; i++) {
		int a, b;
		cin >> a >> b;
		cout << abs(a - b) << endl;

	}
	return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];
string s;

int32_t main(){_

   cin>>n;
   cin >> s;

   stack<char> ms;

   for (int i = 0; i < n; ++i)
   {
      while(!ms.empty() and ms.top() == s[i])
         ms.pop();
      ms.push(s[i]);
   }
   
   cout<<sz(ms);

   return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;

int main() {
    string s;
    cin >> s;
    int a = 0;
    for (int i = 0; i < s.size(); i++) {
        a += s.at(i) - '0';
    }
    int n = stoi(s);
    if (n % a == 0) {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}

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

int main(){

  int n;
  cin >> n;

  if(n>=400 && n<=599){
    cout << 8 << endl;
  }else if(n>=600 && n<=799){
    cout << 7 << endl;
  }else if(n>=800 && n<=999){
    cout << 6 << endl;
  }else if(n>=1000 && n<=1199){
    cout << 5 << endl;
  }else if(n>=1200 && n<=1399){
    cout << 4 << endl;
  }else if(n>=1400 && n<=1599){
    cout << 3 << endl;
  }else if(n>=1600 && n<=1799){
    cout << 2 << endl;
  }else if(n>=1800 && n<=1999){
    cout << 1 << endl;
  }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

struct unionfind_tree{
    int par[500000], rank[500000], num[500000];
    //要素数n(0〜n-1)の初期化されたUnion-Find木を構築
    unionfind_tree(int N){
        rep(i, N){par[i] = i, rank[i] = 0, num[i] = 1;}
    }
    //ノードxの根を取得
    int find(int x){
        if(par[x] == x) return x;
        else return find(par[x]);
    }
    //xとyの属する集合を併合
    void unite(int x, int y){
        x = find(x), y = find(y);
        if(x == y) return;
        elif(rank[x] < rank[y]){par[x] = y, num[y] += num[x];}
        else{
            par[y] = x, num[x] += num[y];
            if(rank[x] == rank[y]) rank[x]++;
        }
    }
    //xの属する集合の要素数を取得
    int size(int x){
        return num[find(x)];
    }
    //xとyが同じ集合に属するか判定
    bool same(int x, int y){
        return find(x) == find(y);
    }
};

int main(){
    int N, M;
    cin >> N >> M;
    int q[N];
    rep(i, N){
        int p;
        cin >> p;
        p--;
        q[p] = i;
    }
    unionfind_tree uft(N);
    rep(i, M){
        int x, y;
        cin >> x >> y;
        x--, y--;
        uft.unite(x, y);
    }
    int ans = 0;
    rep(i, N){
        if(uft.same(i, q[i])) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
const ll nn=1000001;
vector<ll>prime;
ll mark[nn+3];

void sieve()
{
    ll rt=sqrt(nn);
    ll i,j;
    mark[0]=mark[1]=1;
    prime.push_back(2);
    for(i=4; i<=nn; i+=2)
    {
        mark[i]=1;
    }
    for(i=3; i<=rt; i+=2)
    {
        if(mark[i]==0)
        {
            for(j=i*i; j<=nn; j+=2*i)
            {
                mark[j]=1;
            }
        }
    }
    for(i=3; i<=nn; i+=2)
    {
        if(mark[i]==0)prime.push_back(i);
    }
}

int main()
{
    ll a,b,cnt=1,i;
    cin>>a>>b;
    ll gcd;
    gcd=__gcd(a,b);
    sieve();

    for(i=0; prime[i]*prime[i]<=gcd; i++)
    {
        if(gcd%prime[i]==0)
        {
           cnt++;
           while(gcd%prime[i]==0)
           {
               gcd=gcd/prime[i];
           }
        }
    }
    if(gcd!=1)cnt++;
    cout<<cnt<<endl;



    return 0;
}


Measured memory_bytes: 9208
#include<bits/stdc++.h>
#define de(x) cout<<#x<<"="<<x<<endl
#define dd(x) cout<<#x<<"="<<x<<" "
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define repd(i,a,b) for(int i=a;i>=(b);--i)
#define repp(i,a,b,t) for(int i=a;i<(b);i+=t)
#define mt(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp(u,v) make_pair(u,v)
#define sz(a) (int)a.size()
#define pb push_back
#define PI acos(-1.0)
#define qc std::ios::sync_with_stdio(false)
#define all(a) a.begin(),a.end()
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef double db;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;

const ll mod = 1000000007;
const int N = 1e3+6;
const int M = 2e6+6;
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;

bool eq(const db &a, const db &b) { return fabs(a - b) < eps; }
bool ls(const db &a, const db &b) { return a + eps < b; }
bool le(const db &a, const db &b) { return eq(a, b) || ls(a, b); }
ll gcd(ll a,ll b) { return a==0?b:gcd(b%a,a); };
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll kpow(ll a,ll b) {ll res=1;a%=mod; if(b<0) return 1; for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll read(){
    ll x=0,f=1;char ch=getchar();
    while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//inv[1]=1;
//for(int i=2;i<=n;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
int n;
queue<int> q[N];
int to[N];
int main() {
    scanf("%d", &n);
    rep(i, 1, n + 1) {
        rep(j, 1, n) {
            int x; scanf("%d", &x);
            q[i].push(x);
        }
    }
    set<pii> s;
    rep(i, 1, n + 1) {
        int u = i, v = q[i].front();
        if(q[v].front()==u) {
            s.insert({min(u,v), max(u, v)});
        }
    }
    int left = n, ret = 0;
    while(left) {
        set<pii> t; t.clear();
        if(!sz(s)) return printf("-1\n"), 0;
        for(auto tmp: s) {
            int u = tmp.fi,  v = tmp.se;
            q[u].pop();
            q[v].pop();
            if(!sz(q[u])) left--;
            if(!sz(q[v])) left--;
            if(sz(q[u])) {
                int nv = q[u].front();
                if(sz(q[nv])&&q[nv].front()==u) t.insert({min(u,nv), max(u, nv)});
            }
            if(sz(q[v])) {
                int nu = q[v].front();
                if(sz(q[nu])&&q[nu].front()==v) t.insert({min(nu,v), max(nu, v)});
            }
        }
        swap(s, t);
        ret++;
    }
    printf("%d\n", ret);
    return 0;
}


Measured memory_bytes: 4736
import sys
from io import StringIO
import unittest
import os

sys.setrecursionlimit(999999999)


def dfs(now, edge, colors):
    # 枝を全て調査
    for i in edge[now]:
        # 色を設定済みなら何もしない
        if not colors[i[0]] == -1:
            continue

        # 色の設定
        # 親子の距離%2(偶数0:奇数:1) + 親(偶数0:奇数:1) の余りを子に設定(偶数なら0 奇数なら1を設定できるロジック)
        colors[i[0]] = (i[1] % 2 + colors[now]) % 2

        # 再帰処理
        dfs(i[0], edge, colors)


# 実装を行う関数
def resolve():
    n = int(input())
    uvw = [list(map(int, input().split())) for i in range(n - 1)]

    edge = [[] for i in range(n + 1)]

    # 例：edge[0] = [[1, 100][2, 300]]
    # 点0は点1と距離100、点2と距離300でつながっている。
    for i in uvw:
        edge[i[0]].append([i[1], i[2]])
        edge[i[1]].append([i[0], i[2]])

    # -1は「未設定」の意味
    colors = [-1 for i in range(n + 1)]

    # 初期(適当な点を黒に塗る)
    colors[1] = 1

    dfs(1, edge, colors)

    for i in range(1, len(colors)):
        print(colors[i])


# テストクラス
class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """3
1 2 2
2 3 1"""
        output = """0
0
1"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """5
2 5 2
2 3 10
1 3 8
3 4 2"""
        output = """1
0
1
0
1"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()


Measured memory_bytes: 159316
#include<bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define ll long long
#define d1(x)  cerr << #x << "--> " << x << endl
#define d2(x,y)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<endl
#define d3(x,y,z)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z<< endl
#define d4(x,y,z,w)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z << " | "<< #w << "--> " << w <<endl
#define vpll vector<pair<ll,ll>>
#define F first
#define S second
#define T ll tt; cin>>tt; while(tt--)
using namespace std;
ll mode=1e9+7;
const ll maxn=2*1e5+5;
const ll inf=99999999999;
ll __lcm(ll a, ll b){ return (a*b)/__gcd(a,b); }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll getRand(ll l, ll r){ uniform_int_distribution<int> uid(l, r); return uid(rng); }
template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) { return out << "(" << a.F << ", " << a.S << ")"; }
template <class A> ostream& operator << (ostream& out, const vector<A> &v) { 
out << "["; for (int i=0;i<v.size();i++) { if(i) out << ", "; out << v[i]; } return out << "]"; } 


void solve(){


	ll total, legs;
	cin>>total>>legs;
	
	for (int i=0;i<=200;i++){
		for (int j=0;j<=200;j++){
			if ((i+j)==total && (2*i+4*j)==legs){
				cout<<"Yes"<<endl;
				return;
			}
		}
	}
	cout<<"No"<<endl;
	
	return;
}

int main(){ 
    
    #ifndef ONLINE_JUDGE
	//	freopen("input.txt", "r", stdin);
    #endif
    srand(time(0)); 
    
    ios::sync_with_stdio(0);
    cin.tie(0);
 
	
	//T{ solve(); }
	solve();
	
	
	return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>

int main(void)

{

int a,b,c,d ;


scanf("%d",&a) ;

scanf("%d",&b) ;

scanf("%d",&c) ;

if(a>b){

d = b ; b = a ; a = d ;

}

if(a>c){

d = c ; c = a ; a = d ;

}

if(b>c){

d = c ; c = b ; b = d ;

}


printf("%d %d %d\n",a,b,c) ;

return 0 ;

}
  

Measured memory_bytes: 596
/*input
3000
*/
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>

using namespace std; 

int GCD(int x,int y){return y?GCD(y,x%y):x;}
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define rep(i,n) for(int i=0;i<(n);i++)
#define repl(i,a,b) for(int i=(a);i<(b);i++)
#define repm(i,a,b) for(int i=(a);i>(b);i--)
#define rept(v) for(auto it=v.begin();it<v.end();it++)
#define all(v) v.begin(),v.end()
const int INF = 1<<30;
typedef long long ll;
typedef pair<int,int> pii;


  
int main() {
	ll n;
	cin>>n;
	ll b = n%1000;
	if(b>0){
		b = abs(b-1000);
	}
	cout<<b<<endl;
}



Measured memory_bytes: 3600
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0296

N = int(input())

for i in range(N):
	x = input()
	K = int(x.split(" ")[0])
	P = int(x.split(" ")[1])
	if K % P == 0:
		print(str(P))
	else:
		print(str(K % P))

Measured memory_bytes: 7664
#include <iostream>
using namespace std;
int main(void){
    
    int N;
    cin >> N;
    
    int one_keta = N % 10;
    
    if(one_keta == 3){
        cout << "bon" << endl;
    }
    else if(one_keta == 0 || one_keta == 1 || one_keta == 6 || one_keta == 8){
        cout << "pon" << endl;
    }
    else{
        cout << "hon" << endl;
    }
    
    
}


Measured memory_bytes: 3072
/******Old_school_@20******/
#include<bits/stdc++.h>
using namespace std;
#define lld               long long int
#define ld                long double
#define pb                push_back
#define ppb               pop_back 
#define mp                make_pair
#define F                 first
#define S                 second
#define nl                '\n'
#define all(c)            (c).begin(),(c).end()
#define rall(c)           (c).rbegin(),(c).rend()
#define sz(c)             (c).size()
#define tr(x,a)           for(auto &a : x)
#define psnt(x,a)         (x).find(a)!=(x).end()
#define vpsnt(x,a)        find(all(x),a)!=(x).end()
#define lexichar(x,y)     lexicographical_compare(x,x+strlen(x),y,y+strlen(y)) //modify the ranges
#define lexistr(x,y)      lexicographical_compare(x.begin(),x.end(),y.begin(),y.end()) 
#define MOD               1000000007
#define pi                3.1415926536
#define tod               1
#define itr(i,a,b)        for(lld i=a;i<=b;i++)
#define itrn(i,a,b)       for(lld i=a;i>=b;i--)
#define iot(n)            for(lld i=0;i<n;i++)
#define pls(n,arr)        lld arr[n]; iot(n)  cin>>arr[i];
#define bye               fflush(stdout)

typedef pair<lld,lld>     pii;
typedef pair<string,lld>  psi;
template <typename T>
bool mycomp(T x,T y){ 
   return (x==y);  //give your condition here
}
bool paircomp(const pair<lld,lld> &x,const pair<lld,lld> &y){ 
return x.second<y.second;
}

int main(){
       ios_base::sync_with_stdio(false);
             cin.tie(0);
            cout.tie(0);
       string s; cin>>s;
       lld ans=0,cnt=0;
       iot(sz(s)){
           if(s[i]=='R'){
               cnt++;
           }
           else{
             ans=max(ans,cnt);
             cnt=0;
           }
       }ans=max(ans,cnt);
       cout<<ans;
}


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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%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);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
// 出力は.xで！！！！

int main(){
  int n,k; cin >> n >> k;
  vector<vector<int> > ki(n);
  rep(i,n-1){
    int a,b; cin >> a >> b;
    a--; b--;
    ki[a].push_back(b);
    ki[b].push_back(a);
  }
  vector<int> ko(n,0);
  queue<P> nord;
  nord.push(P(0,-1));
  mint ans=1;
  while(!nord.empty()){
    int now=nord.front().first;
    int par=nord.front().second;
    nord.pop();
    if(par==-1) ans*=k;
    else{
      int num=2;
      if(par==0) num=1;
      ans*=k-(num+ko[par]);
      ko[par]++;
    }
    rep(i,ki[now].size()){
      if(ki[now][i]==par) continue;
      nord.push(P(ki[now][i],now));
    }
  }
  cout << ans.x << endl;
return 0;
}

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

long long pow(long long a,long long b,long long mod){
    if(b==0){
        return 1;
    }else{
        if(b%2==0){
            return pow(a*a%mod,b/2,mod);
        }else{
            return pow(a*a%mod,b/2,mod)*a%mod;
        }
    }

}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

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

    long long ans=0;
    long long mod=1000000007;
    int sign=1;
    vector<long long> perm(N+1);//MP0~MPN
    vector<long long> perm2(N+1);//M-SPN-S
    perm[0]=1;
    for(int i=1;i<=N;i++){
        perm[i]=perm[i-1]*(M+1-i);
        perm[i]%=mod;
    }
    perm2[N]=1;
    for(int i=N-1;i>=0;i--){
        perm2[i]=perm2[i+1]*(M-i);
        perm2[i]%=mod;
    }

    long long tmp;
    long long comb=1;
    for(int i=0;i<=N;i++){
        //cout<<"comb:"<<comb<<endl;
        tmp=(sign*perm[i]*comb)%mod;
        tmp*=(perm2[i]*perm2[i])%mod;
        //cout<<"perm:"<<perm[i]<<" "<<perm2[i]<<endl;
        tmp%=mod;
        //cout<<"tmp:"<<tmp<<endl;
        ans+=tmp;
        ans%=mod;
        sign*=-1;
        comb*=(N-i);
        comb%=mod;
        comb*=modinv(i+1,mod);
        comb%=mod;
    }
    ans+=mod;
    ans%=mod;
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 11068
// Problem : A - Registration
// Contest : AtCoder - AtCoder Beginner Contest 167
// URL : https://atcoder.jp/contests/abc167/tasks/abc167_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define pb push_back
#define mp make_pair
#define y1 y114514
#define y2 y1919810
typedef pair <int, int> PII;
//#define int long long
#define all(x) (x.begin(),  x.end())
#define lsh(i) (1 << (i))
#define lshll(i) (1LL << (i))
#define repn(i, n) for (int i = 1; i <= (int)n; i++)
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define range(i, s, t)  for (int i = s; i <= (int)t; i++)
const int INF = 0x3f3f3f3f;
const long double EPS = 1e-6;
long long qread() {
	char c = getchar();
	int neg = 1;
	long long val = 0;
	while (c != '-' && !isdigit(c)) c = getchar();
	if (c == '-') c = getchar(), neg = -1;
	while (isdigit(c)) val = (val << 3) + (val << 1) + c - '0', c = getchar();
	return neg * val;
}
int main() {
	string s, t;
	cin >> s >> t;
	for (int i = 0; i < s.length(); i++) if (s[i] != t[i]) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;

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

        int count = 0;
        int N = sc.nextInt();
        int[] x;
        x = new int[100];

        for (int i = 0; i < N; i++) {
            x[i] = sc.nextInt();
        }

        for (int i = 0; i < N; i++) {
            int minj = i;
            for (int j = i+1; j < N; j++) {
                if (x[minj] > x[j]) {
                    minj = j;
                }
            }

                if (minj != i) {
                    int temp = x[i];
                    x[i] = x[minj];
                    x[minj] = temp;
                    count++;
                }
        }

            for (int i = 0; i < N - 1; i++) {
                System.out.print(x[i] + " ");
            }
            System.out.println(x[N - 1]);
            System.out.println(count);
    }
}


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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// ordered_set X;
// *X.find_by_order(i) = ith largest element (counting from zero)
// X.order_of_key(k) = number of items in X < k (strict lt)

bool mycomp (pair<ll, ll> x1, pair<ll, ll> x2) {
    ll a1 = x1.first;
    ll b1 = x1.second;
    ll a2 = x2.first;
    ll b2 = x2.second;

    return (a1*b2 > b1*a2);
}

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

    int N;
    ll T;
    cin >> N >> T;
    vll A(N);
    vll B(N);

    for (int i=0;i<N;i++) cin >> A[i] >> B[i];

    vector<pair<ll, ll>> funcs;
    vll zeros;
    for (int i=0;i<N;i++) {
        if (A[i] > 0) {
            funcs.push_back({A[i], A[i] + B[i] + 1});
        } else {
            zeros.push_back(B[i]+1);
        }
    }

    sort(funcs.begin(), funcs.end(), mycomp);
    sort(zeros.begin(), zeros.end());

    // for (auto func : funcs) {
    //     cout << func.first << " " << func.second << endl;
    // }

    int M = funcs.size();
    vll dprow(M,T+1);
    vvll dp(40, dprow);

    for (int i=0;i<M;i++) dp[0][i] = 0;
    for (int i=1;i<40;i++) {
        ll cmin = T+1;
        if (i==1) cmin = 0;
        for (int j=0;j<M;j++){
            if (cmin < T) {
                ll a = funcs[j].first;
                ll b = funcs[j].second;
                dp[i][j] = min(dp[i][j], (a+1)*cmin + b);
            }

            cmin = min(cmin, dp[i-1][j]);
        }
    }

    // for (int i=0;i<5;i++) {
    //     cout << i << ": ";
    //     for (int j=0;j<M;j++) cout << dp[i][j] << " ";
    //     cout << endl;
    // }

    int Z = zeros.size();
    vll czeros(Z+1, 0);
    for (int i=0;i<Z;i++) czeros[i+1] = czeros[i] + zeros[i];

    int ans = 0;
    for (int i=0;i<40;i++) {
        ll best = T+1;
        if (i == 0) best = 0;
        for (int j=0;j<M;j++) {
            best = min(best, dp[i][j]);
        }

        // cout << i << " " << best << endl;

        if (best <= T) {
            auto low = upper_bound(czeros.begin(), czeros.end(), T-best);
            int num_lt = (low - czeros.begin());
            num_lt--;

            ans = max(ans, i + num_lt);
        }

        
        
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;


void solve() {
    int n; cin >> n;
    vector<pair<int, int>> a,b;
    int sum = 0;
    for (int _ = 0; _ < n; _++) {
        string s; cin >> s;
        int x = 0, mi = 0;
        for (char c:s) {
            if (c=='(')x++;
            else x--;
            mi = min(mi, x);
        }
        sum += x;
        if (x > 0) a.emplace_back(mi, x);
        else b.emplace_back(mi-x, -x);
    }
    if (sum != 0) {
        cout << "No"; return;
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    reverse(a.begin(), a.end());
    reverse(b.begin(), b.end());
    auto ck = [](auto a){
        int x = 0;
        for (auto& p: a) {
            int mi,d;
            tie(mi,d) = p;
            if (x+mi<0) {
                return false;
            }
            x += d;
        }
        return true;
    };
    if (ck(a)&&ck(b)) {
        cout << "Yes";
    } else {
        cout << "No";
    }
}

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


Measured memory_bytes: 18796
N = int(input())
reg = [input() for i in range(N)]
M = int(input())
src = [input() for i in range(M)]

closed = True
for name in src:
    if name in reg:
        closed = not closed
        print(('Closed' if closed else 'Opened') + ' by ' + name)
    else:
        print('Unknown ' + name)

Measured memory_bytes: 5644
#include<bits/stdc++.h>
using namespace std;
vector<int>s[100009];
priority_queue<int>q;
int n,m,x,t[100009];
long long ans;
int main(){
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%d",&t[i]);
		scanf("%d",&x);
		t[i]=m-t[i]+1;
		if(t[i]<=0)continue;
		ans+=x;
		// x=-x;
		s[t[i]].push_back(x);
		// printf("%d %d\n",x,t[i]);
	}
	for(int i=100000;i>=1;i--){
		for(int j=0;j<s[i].size();j++)q.push(s[i][j]);
		if(q.size()>0)q.pop();
	}
	while(!q.empty())ans-=q.top(),q.pop();
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

#define ll long long
#define pi pair<int, int>
#define pb push_back
#define fr first
#define sc second
#define endl '\n'

const int mxn = 1e6 + 5;
const ll MOD = 1e9 + 7;
int arr[mxn];
int n, m, k;
string s, t;

ll pow(ll A,ll B,ll R=1)
{while(B){if(B&1)R=R*A%MOD;A=A*A%MOD;B>>=1;}return R;}


void read(){
    cin >> n >> m;
    for(int i = 0, u, v; i < m; i++){
        cin >> arr[i];
    }
}

void solve(){
    int sum = 0;
    for(int i = 0; i < m; i++) sum += arr[i];
    int res = n - sum;
    res = max(res, -1);
    cout << res << endl;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int T = 1;
    //cin >> T;
    while(T--) read(), solve();
    return 0;
}


Measured memory_bytes: 3660
//20190116 20:10
#include <iostream>
#include <vector>

using namespace std;

void vec_cin(vector<int> &vec){
    for(int i=0; i<vec.size(); i++){
        cin >> vec[i];
    }
}

int main(){
    long long MOD = 1000000007;
    int n,m;
    cin >> n >> m;

    vector<int> x(n);
    vector<int> y(m);
    long long H=0;
    long long W=0;

    vec_cin(x);
    vec_cin(y);

    for(int i=0; i<m-1; i++){
        H+=(long long) (y[i+1]-y[i])*(i+1)*(m-i-1);
        H%=MOD;
    }
    for(int i=0; i<n-1; i++){
        W+=(long long) (x[i+1]-x[i])*(i+1)*(n-i-1);
        W%=MOD;
    }
    cout << (H*W)%MOD << endl;

}

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

using namespace std;

int main() {
    int N;
    int dp[100001];

    cin >> N;

    dp[0] = 0;
    for (int i = 1; i <= N; i++) {
        int power = 1;

        dp[i] = INT_MAX;

        while (power <= i) {
            dp[i] = min(dp[i], dp[i-power]+1);
            power *= 9;
        }

        power = 1;
        while (power <= i) {
            dp[i] = min(dp[i], dp[i-power]+1);
            power *= 6;
        }
    }

    cout << dp[N] << endl;
    return 0;
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int m;
ll ans, sum; 

ll count(ll digit, ll times) {
    if (times == 1) return digit;
    else {
        ll tmp = digit * 2, moves = 1;
        if (tmp >= 10) {
            ++moves;
            tmp = tmp % 10 + 1;
        }

        ans += (times / 2) * moves;
        ll res = count(tmp, times / 2);
        if (times % 2) {
            tmp = digit + res, moves = 1;
            if (tmp >= 10) {
                ++moves;
                tmp = tmp % 10 + 1;
            }
            ans += moves;
            res = tmp;
        }
        return res;
    }
}

int main() {
	cin.tie(0)->sync_with_stdio(0);
    cin >> m;
    for (int i = 0; i < m; ++i) {
        ll d, c;
        cin >> d >> c;
        if (sum) ++ans;
        sum += count(d, c);
        if (sum >= 10) {
            sum = sum % 10 + 1;
            ++ans;
        }
    }
    cout << ans;
}


Measured memory_bytes: 3576
def resolve():
    N, M = [int(i) for i in input().split()]
    kk, ss = [], []
    for _ in range(M):
        k, *s = [int(i) for i in input().split()]
        kk.append(k)
        ss.append(s)
    p = [int(i) for i in input().split()]
    ans = 0
    for i in range(2**N):
        lights = [0] * M
        for j in range(M):
            count = 0
            for sw in ss[j]:
                if (i >> (sw - 1)) & 1:
                    count += 1
            if count % 2 == p[j]:
                lights[j] = 1
        if 0 not in lights:
            ans += 1
    print(ans)


resolve()


Measured memory_bytes: 3064
import java.util.Scanner;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.ArrayDeque;
import java.io.*;
public class Main{
	public static void main(String[] args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int[] v= {-4, -1, 1, 4};
        Map<String, Integer> mini = new HashMap<String, Integer>();
        mini.put("01234567",0);
        
        Queue<String> que= new ArrayDeque<>();
        que.add("01234567");
        while(!que.isEmpty()){
            String s = que.element();
            que.remove();
            int n = 0;
            for(int i = 0; i < 8; i++){
                if(s.charAt(i) == '0'){
                    n = i;
                    break;
                }
            }
            
            for (int i = 0; i < 4; i++) {
                int m = n + v[i];
                if(m < 0||7 < m) continue;
                if(n == 3 & m == 4)continue;
                if(n == 4 & m == 3)continue;
                char c = s.charAt(m);
                String sub_1 = s.replace('0', 'A');
                String sub_2 = sub_1.replace(c, '0');
                String news = sub_2.replace('A',c);
                if(!mini.containsKey(news)){
                    mini.put(news, mini.get(s) + 1);
                    que.add(news);
                }
            }
        }

        try {String str;
            while((str = reader.readLine()) != null){
                char[] ch = new char[8];
                for(int i = 0; i < 8; i++){
                    char sub = str.charAt(i*2);
                    ch[i] = sub;
                }
                String index = new String(ch);
                System.out.println(mini.get(index));
            }
        }catch (IOException e){
            System.out.println(e);
        }  
    }
}


Measured memory_bytes: 38092
#include<bits/stdc++.h>
using namespace std;
int i,j,m,n,p,ii,o;
int a[105][105];
int r[105],c[105];
int main()
{
  char u;
  cin>>m>>n;
  //read
   for(i=1;i<=m;i++)
   {
   	 int t=0;
  	 for(j=1;j<=n;j++)
   	 {
   	 	cin>>u;
   	 	if(u=='#') a[i][j]=0;
   	 	else {
   	 	a[i][j]=1;
   	 	t++;
   	     }
   	 }
     r[i]=t;
     
   }
    
   //column
   for(j=1;j<=n;j++)
   {
   	 int t=0;
   	 for(i=1;i<=m;i++)
   	 {
   	 	if (a[i][j]==1) t++;
   	 }
   	 c[j]=t;
  
   }
    
   
   for(i=1;i<=m;i++)
   {
   	  int t=0;
   	 for(j=1;j<=n;j++)
   	 {
   	 	
   	   if(r[i]!=n&&c[j]!=m)
		{
			t=1;
		   if (a[i][j]==0) cout<<"#";
   	 	   if (a[i][j]==1) cout<<".";
         	 }
    }
   	 if (t) cout<<endl; 
   }
  return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use  std::collections::BTreeSet;
use std::cmp::min;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("faild to read char") as char)
        .take_while(|c| !c.is_whitespace())
        .collect();
    token
        .parse()
        .ok()
        .expect("faild to parse token")
}

fn main(){
    let k: u8 = read();
    let mut ret: u64 = 0;
    for i in 1..(k + 1) {
        for j in 1..(k + 1) {
            for k in 1..(k + 1) {
                ret += gcd3(i, j, k) as u64;
            }
        }
    }
    println!("{}", ret);
}

fn gcd(a: u8, b: u8) -> u8 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn gcd3(a: u8, b: u8, c: u8) -> u8 {
    gcd(gcd(a, b), c)
}


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

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define rsz resize
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define odd(x) ((x) % (2))
#define fastio ios_base::sync_with_stdio(false), cin.tie(0);
#define fileio freopen("template.in", "r", stdin), freopen("template.out", "w", stdout);
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const ll MOD = 1e9 + 7;

int main() {
    fastio;
    //fileio;
        
    int n;
    cin >> n;
    vi L;
    FOR(i, 0, n) {int x; cin >> x; L.pb(x);}
    int size = L.size();
    // FOR(i, 0, size) {
    //     FOR(j, i+1, size) {
    //         if (L[i] == L[j]) {L.erase(L.begin() + j, L.begin()+j+1); size--;}
    //     }
    // }
    int answer = 0;
    FOR(i, 0, size) {
        FOR(j, i+1, size) {
            FOR(k, j+1, size) {
                if (!(L[i] == L[j] || L[j] == L[k] || L[i] == L[k])) {
                    if (L[i] + L[j] > L[k] && L[j] + L[k] > L[i] && L[i] + L[k] > L[j]) {
                        cerr << i << " " << j << " " << k << "\n";
                        answer++;
                    }
                }
            }
        }
    }
    cout << answer << "\n";
    return 0;
}


Measured memory_bytes: 3676
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
#include <utility>
using Pli = std::pair<long long, int>;

int main()
{
    int n, k;
    std::cin >> n >> k;
    std::vector T(n, std::vector<long long>(0));

    for (int i = 0; i < n; i++)
    {
        int t;
        long long d;
        std::cin >> t >> d;
        T.at(t - 1).push_back(d);
    }
    std::vector Top(0, std::pair<long long, int>());
    for (int i = 0; i < n; i++)
    {
        if (!T.at(i).empty())
        {
            std::sort(T.at(i).begin(), T.at(i).end(), std::greater<long long>());
            Top.push_back({T.at(i).at(0), i});
        }
    }
    std::sort(Top.begin(), Top.end(), std::greater<Pli>());

    long long ans = 0, s = 0;
    //std::priority_queue<long long> sushi(std::greater<long long>(),std::vector<long long>());
    std::priority_queue<long long, std::vector<long long>, std::greater<long long>> sushi;
    int l = 0;
    for (long long j = 0; j < std::min(k, int(Top.size())); j++)
    {
        long long t = Top.at(j).first;
        int i = Top.at(j).second;

        s += t;
        if (l + j + 1 > k)
        {
            s -= sushi.top();
            sushi.pop();
            l -= 1;
        }
        for (int m = 1; m < int(T.at(i).size()); m++)
        {
            long long will = T.at(i).at(m);
            if (l + j + 1 >= k)
            {
                s += will;
                sushi.push(will);
                s -= sushi.top();
                sushi.pop();
            }
            else
            {
                s += will;
                l += 1;
                sushi.push(will);
            }
        }
        ans = std::max(ans, s + (j + 1) * (j + 1));
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 10812
import java.util.Scanner;

public class Main { 
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	String st = sc.nextLine();
    	final String  Sunny = "Sunny";
    	final String Cloudy = "Cloudy";
    	final String Rainy = "Rainy";
    	String result = "";
    	if(Sunny.equals(st)) {
    		result = Cloudy;
    	}else if(Cloudy.equals(st)) {
    		result = Rainy;
    	}else if(Rainy.equals(st)) {
    		result = Sunny;
    	}

    	https://atcoder.jp/contests/abc141/custom_test
    	
    	System.out.println(result);
    	
    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<string>
using namespace std;
string s;
bool flag=false;
int main() {
	cin>>s;
	for(int i=0; i<=s.size(); i++) {
		if(flag&&s[i]=='F') {
			cout<<"Yes"<<endl;
			return 0;
		}
		if(s[i]=='C') flag=true;
	}
	cout<<"No"<<endl;
	return 0;
}

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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int a = sc.NextInt();
        int b = sc.NextInt();
        int c = sc.NextInt();

        int answer = (b == c) ? a : (a == b ? c : b);

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <vector>
#include <tuple>
#include <cmath>
#include <set>
#include <map>

using namespace std;
#define iter(b) for(int i = 0;i < (b);i++)
#define VVI vector<vector<int>>

map<pair<int, int>, int> memo;

int gcd(int a, int b){
    if(a < b) return gcd(b, a);
    auto p = make_pair(a, b);
    if(memo.find(p) != memo.end()){
        return memo.at(p);
    }
    if(b == 0) return a;
    int d = gcd(b, a % b);
    memo.insert({p, d});
    return d;
}

int main(){
    int K;
    cin >> K;
    int sum = 0;
    for(int a = 1;a <= K;a++){
        for(int b = 1;b <= K;b++){
            for(int c = 1;c <= K;c++){
                sum += gcd(a, gcd(b, c));
            }
        }
    }
    cout << sum;
}

Measured memory_bytes: 4812