akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){
	char **weather;
  weather= (char**)malloc(sizeof(char*)*3);
  weather[0]="Sunny";
  weather[1]="Cloudy";
  weather[2]="Rainy";
  char today[10];
  scanf("%s",today);
  for(int i=0;i<3;i++){
  	if(strcmp(today,weather[i])==0){
		printf("%s\n",weather[(i+1)%3]);
        break;
    }
  }
  return 0;
}


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

using namespace std;

int main(void) {
	int num, i;
	long long ans = 0;
	cin >> num;
	vector<int> a(num + 1, 0), b(num, 0);
	for (i = 0; i <= num; i++)
		scanf("%d", &a[i]);
	for (i = 0; i < num; i++)
		scanf("%d", &b[i]);
	for (i = 0; i < num; i++) {
		ans += min(a[i], b[i]) + min(a[i + 1], max(0, b[i] - a[i]));
		a[i + 1] -= min(a[i + 1],max(0, b[i] - a[i]));
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

using System.Collections;

class Program
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());

        var lis = Enumerable.Range(0, N).Select(n => Console.ReadLine()).ToList();

        
        bool rule1 = lis.Zip(lis.Skip(1), (s1, s2) => new { s1, s2 }).All(itm => itm.s1.Last() == itm.s2.First());
        bool rule2 = (lis.Count == lis.Distinct().Count());

        if (rule1 && rule2)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
    
}


static class MathUtil
{
    public static T Max<T>(params T[] datas)
    {
        return datas.Max();
    }

    public static T Min<T>(params T[] datas)
    {
        return datas.Min();
    }

    public static IEnumerable<IEnumerable<int>> GetPermutation(int n)
    {
        if (n == 0)
        {
            yield return Single(0);
            yield break;
        }

        for (int i = 0; i <= n; i++)
        {
            foreach (var x in GetPermutation(n - 1))
            {
                yield return Single(i).Concat(x.Select(itm => itm < i ? itm : itm + 1));
            }
        }
    }

    private static IEnumerable<int> Single(int x)
    {
        yield return x;
    }

    public static IEnumerable<int> EnumeratePrimeNumbers()
    {
        List<int> primes = new List<int>() { 2 };
        yield return 2;

        for (int i = 3; i < int.MaxValue; i++)
        {
            bool isPrime = true;
            int Sqrt = (int)Math.Sqrt(i) + 1;

            foreach (var prime in primes)
            {
                if (prime > Sqrt)
                {
                    break;
                }
                if (i % prime == 0)
                {
                    isPrime = false;
                    break;
                }
            }

            if (isPrime)
            {
                primes.Add(i);
                yield return i;
            }
        }
    }
}




Measured memory_bytes: 11604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAX_S 100000
#define MOD 1000000007
ll  C[MAX_S], QC[MAX_S], BC[MAX_S], QBC[MAX_S], BQC[MAX_S], QBQC[MAX_S], three[MAX_S];

int main(){	
	string S;
	cin >> S;
	ll q = 0, c = 0, qc = 0, bc = 0, qbc = 0, bqc = 0, qbqc = 0, res = 0;
	three[0] = 1;
	for (int i=1; i<MAX_S; i++) three[i] = (3*three[i-1])%MOD;
	for (int i=0; i<S.length(); i++) if (S[i] == '?') q++;
	for (int i=S.length()-1; i>=0; i--) {
		if (S[i] == 'C') {
			c++;
		}
		C[i] = c;
		if (S[i] == '?') {
			qc++;
		}
		QC[i] = qc;
	}
	for (int i=S.length()-2; i>=0; i--) {
		if (S[i] == 'B') {
			bc = (bc+C[i+1])%MOD;
			bqc = (bqc+QC[i+1])%MOD;
		}
		BC[i] = bc;
		BQC[i] = bqc;
		if (S[i] == '?') {
			qbc = (qbc+C[i+1])%MOD;
			qbqc = (qbqc+QC[i+1])%MOD;
		}
		QBC[i] = qbc;
		QBQC[i] = qbqc;
	}
	for (int i=S.length()-3; i>=0; i--) {
		if (S[i] == 'A') {
			res = (res+BC[i+1]*three[max(q, 0LL)])%MOD;
			res = (res+BQC[i+1]*three[max(q-1, 0LL)])%MOD;
			res = (res+QBC[i+1]*three[max(q-1, 0LL)])%MOD;
			res = (res+QBQC[i+1]*three[max(q-2, 0LL)])%MOD;
			// cout << "i: " << i << endl;
			// cout << "BC[i+1]: " << BC[i+1] << endl;
			// cout << "BQC[i+1]: " << BQC[i+1] << endl;
			// cout << "QBC[i+1]: " << QBC[i+1] << endl;
			// cout << "QBQC[i+1]: " << QBQC[i+1] << endl;
		}
		if (S[i] == '?') {
			res = (res+BC[i+1]*three[max(q-1, 0LL)])%MOD;
			res = (res+BQC[i+1]*three[max(q-2, 0LL)])%MOD;
			res = (res+QBC[i+1]*three[max(q-2, 0LL)])%MOD;
			res = (res+QBQC[i+1]*three[max(q-3, 0LL)])%MOD;
			// cout << "i: " << i << endl;
			// cout << "BC[i+1]: " << BC[i+1] << endl;
			// cout << "BQC[i+1]: " << BQC[i+1] << endl;
			// cout << "QBC[i+1]: " << QBC[i+1] << endl;
			// cout << "QBQC[i+1]: " << QBQC[i+1] << endl;
		}
	}
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 5888
using System;
using System.Collections.Generic;

namespace MyProgram{
    class AtCoder{
        static void Main(){
            int N = int.Parse(Console.ReadLine());
            string[] S = new string[N];
            for(var i=0;i<N;i++){
                S[i] = Console.ReadLine();
            }
            long[] march = {0,0,0,0,0};
            for(var i=0;i<N;i++){
                switch(S[i][0]){
                    case 'M':
                        march[0]++;
                        break;
                    case 'A':
                        march[1]++;
                        break;
                    case 'R':
                        march[2]++;
                        break;
                    case 'C':
                        march[3]++;
                        break;
                    case 'H':
                        march[4]++;
                        break;
                    default:
                        break;
                }
            }
            long sum=0;
            for(var i=0;i<3;i++){
                for(var j=i+1;j<4;j++){
                    for(var k=j+1;k<5;k++){
                        sum += march[i] * march[j] * march[k];
                    }
                }
            }
            Console.WriteLine(sum);

        }
    } 
}

Measured memory_bytes: 15712
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int sum = a+b+c;
    int x = max(a, max(b, c))*3;
    if ((x-sum)%2==1) x += 3;
    
    int ans = (x-sum)/2;
    
    cout << ans << endl;
    return 0;
}


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

using namespace std;

typedef pair<int, int> P;
typedef long long ll;


template <typename T> void show_vec(vector<T> v);





int main(){

    

    //solve();
    int a, b;
    cin >> a >> b;
    cout << a*b << endl;

    return 0;

}

template <typename T> void show_vec(vector<T> v){
    cout << "[";
    for (int i = 0; i < (int)v.size(); i++)
    {
        cout << v[i] << ",";
    }
    cout << "]" << endl;
}

Measured memory_bytes: 3636
// Crt. 2019-12-17  15:06:28
// 有心栽花花不开,无心插柳柳成荫.
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <queue>
#define N 400005
#define PII pair<int, int>
using namespace std;

int n, m;
bool vis[N], ok[N];
PII p[N];

inline bool cmp(PII a, PII b) {
    return a.second > b.second;
}

int main() {
#ifdef LOCAL_JUDGE
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif

    cin >> n >> m;
    for (int i = 1; i <= n; ++i)
        scanf("%d%d", &p[i].first, &p[i].second);

    sort(p + 1, p + n + 1);

    priority_queue<PII, vector<PII>, greater<PII> > q;

    int now = 1;
    for (int i = 1; i <= n; ++i) {
        while (now <= m && vis[now]) ++now;
        if (now > m) break; vis[now] = 1;
        q.push(make_pair(p[i].second, i)), ok[i] = 1;
        if (now > p[i].first) ok[q.top().second] = 0, q.pop(), vis[now] = 0;
//        cout << i << "#" << now << " " << vis[now] << endl;
    }

//    for (int i = 1; i <= n; ++i)
//        cout << p[i].first << " " << p[i].second << " " << ok[i] << " " << vis[i]<< endl;

    if (now > m) return cout << n - m, 0;

    int cnt = 0;
    for (int i = 1; i <= n; ++i)
        if (!ok[i]) p[++cnt] = p[i];
    n = cnt;

    sort(p + 1, p + n + 1, cmp);

    int res = 0; now = m;
    for (int i = 1; i <= n; ++i) {
        while (now && vis[now]) --now;
        //if (!now) return cout << i + res << endl, 0;
        if (now >= p[i].second) vis[now] = 1;
        else ++res;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 4340
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc;

	static final int INF=1<<28;
	static final double EPS=1e-9;

	void run(){
		sc=new Scanner(System.in);
		for(int t=1;; t++){
			int maxWeight=sc.nextInt();
			if(maxWeight==0)
				break;
			int n=sc.nextInt();
			sc.nextLine();
			int[] values=new int[n];
			int[] weights=new int[n];
			for(int i=0; i<n; i++){
				String[] s=sc.nextLine().split(",");
				values[i]=Integer.parseInt(s[0]);
				weights[i]=Integer.parseInt(s[1]);
			}
			int[] dp=new int[maxWeight+1];
			int[] pdp=new int[maxWeight+1];
			for(int j=0; j<n; j++){
				System.arraycopy(dp, 0, pdp, 0, maxWeight+1);
				for(int i=0; i<=maxWeight; i++){
					if(i<weights[j])
						dp[i]=pdp[i];
					else
						dp[i]=max(pdp[i], pdp[i-weights[j]]+values[j]);
				}
			}
			int weight;
			for(weight=maxWeight; dp[weight]==dp[maxWeight]&&weight>=0; weight--);
			println("Case "+t+":");
			println(dp[maxWeight]+"");
			println(weight+1+"");
		}
		sc.close();
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 12000
H, N = gets.chomp.split.map(&:to_i)

ab = []
N.times do
  ab << gets.chomp.split.map(&:to_i)
end

dp = Array.new(H+1, Float::INFINITY)
dp[0] = 0

ab.sort!{ |a, b| a[0] <=> b[0]}
# O(NH)
# 各HPに対してダメージコストでeachを回す
# dp[h] h減らすまでのコストの最小値

1.upto(H) do |hp|
  ab.each do |damage, cost|
    tmp_cost = damage >= hp ? cost : dp[hp-damage] + cost
    dp[hp] = tmp_cost if dp[hp] > tmp_cost
  end
end

p dp.last

Measured memory_bytes: 3836
package main
import (
	"fmt"
)

func main() {
	var (
		n int
		money float64
		currency string
	)

	fmt.Scan(&n)
	total := 0.0
	for i := 0; i < n; i++ {
		fmt.Scan(&money, &currency)
		if currency == "BTC" {
			money *= 380000.0
		}
		total += money
	}

	fmt.Println(total)
}


Measured memory_bytes: 512
use std::fs;
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let s = it.next().unwrap().chars().collect::<Vec<char>>();
    let n = s.len();
    if !(0..n).all(|i| s[i] == s[n - i - 1]) {
        println!("{}", "No");
        return;
    }
    if !(0..((n - 1) / 2)).all(|i| s[i] == s[(n - 1) / 2 - i - 1]) {
        println!("{}", "No");
        return;
    }
    println!("{}", "Yes");
}

fn test() {
    let mut f = fs::File::open("foo.txt").unwrap();
    let mut s = String::new();
    f.read_to_string(&mut s).unwrap();
    solve(&s);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_main() {
        test();
    }
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MOD 1000000007
#define ll long long int
#define pair <ll, ll> pi
#define vector <ll> vi
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define SQ(a) (a) * (a)
#define ordered_set tree<ll, null_type, greater_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> //greater_equal<ll> or less<ll>
// find_by_key()   order_of_key()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
/*bool comp(string a, string b) {
if (a.size() != b.size()) return a.size() < b.size();
return a < b;
}*/

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen('input.txt', 'r', stdin);
    //freopen('output.txt', 'w', stdout);
    ll i, j, k, n, m, b, d, t, ans = 0,a,x,y,flag=0;
    cin>>n;
    for(i=sqrt(n);i>=1;i--){
        if(n%i==0 && i<=9 && (n/i)<=9){
            cout<<"Yes"<<endl;
            flag=1;
            break;
        }
        
    }
    if(flag==0){
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3664
N,K,S = map(int, input().split())

ans = [0]*N
if K == N:
    ans = [S]*N
elif S == 1 or S == 10**9:
    for i in range(K):
        ans[i] = S
    for i in range(K, N):
        ans[i] = 10
else:
    p = S-1
    q = 1
    for i in range(K+1):
        if i%2 == 0:
            ans[i] = p
        else:
            ans[i] = q
    
    for i in range(K+1, N):
        ans[i] = 10**9

print(*ans)

Measured memory_bytes: 46652
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ini(a,i) memset(a,i,sizeof(a))
#define pb push_back
#define int int64_t
#define inf LLONG_MAX

void solve()
{
    int n,x,t,i,ans,cnt;
    cin>>n>>x>>t;

    ans=0;cnt=0;

    while(cnt < n)
    {
        ans+=t;
        cnt+=x;
    }

    cout<<ans<<endl;

}


signed main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    // int tt;    cin>>tt;    while(tt--)
        solve();
     
    cerr<<" Execution : "<<(1.0*clock())/CLOCKS_PER_SEC<<"s \n";
        
        
return 0;
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
#define INF (1e18)

struct Combination{
private:
    ll N;
    vector<ll> fac, facinv;

public:
    Combination(ll n){
        N = n;
        fac.push_back(1); fac.push_back(1);
        rep(i,2,N+1) fac.push_back(fac[i-1] * i % MOD);
        rep(i,0,N+1) facinv.push_back(power(fac[i], MOD-2));
    }
    ll power(ll x, ll n){
        if(n == 0) return 1LL;
        ll res = power(x * x % MOD, n/2);
        if(n % 2 == 1) res = res * x % MOD;
        return res;
    }
    ll nck(ll n, ll k){
        if(k == 0 || n == k) return 1LL;
        return fac[n] * facinv[k] % MOD * facinv[n-k] % MOD;
    }
    ll npk(ll n, ll k){
        if(k == 0 || n == k) return 1LL;
        return fac[n] * facinv[n-k] % MOD;
    }
    ll get(ll x){return fac[x];};
    ll getinv(ll x){return facinv[x];};
};
ll dp[1010][1010] = {};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    Combination comb(100010);
    ll N,A,B,C,D;
    cin >> N >> A >> B >> C >> D;
    dp[0][N] = 1;
    ll val[1010] = {};
    rep(i,0,1010){
        val[i] = comb.power(i,MOD-2);
    }
    rrep(q,N,0){
        rep(p,1,A){
            dp[p][q] += dp[p-1][q];
            dp[p][q] %= MOD;
        }
        rep(p,A,B+1){
            dp[p][q] += dp[p-1][q]; //一つも作らない
            dp[p][q] %= MOD;
            ll v = dp[p-1][q];
            for(int i = 1; i <= D && i <= q/p; i++){
                v *= (comb.nck(q-(i-1)*p, p) * val[i]) % MOD;
                v %= MOD;
                if(i >= C){
                    dp[p][q-i*p] += v;
                    dp[p][q-i*p] %= MOD;
                }
            }
        }
    }
    print(dp[B][0]);
    
}

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

int main() {
  int N;
  cin >> N;
  if(N%2==0) {
    cout << ((double)(N/2)) / ((double)N) << endl;
  } else {
    cout << ((double)(N/2+1)) / ((double)N) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#define ll long long int
#define mod 1000000007
using namespace std;
int main() 
{
    int n;cin>>n;
	 string s,t;
	 cin>>s>>t;
	 for(int i=0,j=0;i<n;i++,j++)
	 {
	 	cout<<s[i]<<t[i];
	 }
	 
	}
 
 

Measured memory_bytes: 256
#include <stdio.h>


int main()
{
	int S,h,m,s;

	scanf("%d",&S);
	h = S / 3600;
	m = (S - h*3600) / 60;
	s = (S - h * 3600 - m * 60);
	printf("%d:%d:%d\n",h,m,s);
    return 0;
}

Measured memory_bytes: 1812
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

int main() {
	//頂点数と辺数
	int N, M;
	cin >> N >> M;

	//graph受け取り
	Graph G(N);
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		G[a-1].push_back(b - 1);
		G[b-1].push_back(a - 1);
	}

	//dataforBFS
	vector<int> dist(N, -1);//訪問フラグ
	vector<int> sign(N, -1);//道しるべ
	queue<int> que;

	//初期条件
	dist[0] = 0;
	que.push(0);

	//BFSここから
	while (!que.empty()) {
		int v = que.front();
		que.pop();

		//vからたどれる頂点を全て調べる
		for (int nv : G[v]) {
			if (dist[nv] != -1) continue; //すでに発見済みの頂点はスルー

			//新たな白色頂点nvについて距離情報を更新してキューに追加
			dist[nv] = dist[v] + 1;
			que.push(nv);
		}
	}
	for (int i = 1; i < N; i++) {
		for (int j = 0; j != G[i].size(); ++j) {
			int v = G[i][j];
			if (dist[v] < dist[i]) {
				sign[i] = v;
				break;
			}
		}
	}
	for (int i = 1; i < N; i++) {
		if (sign[i] == -1) {
			cout << "No" << endl;
			exit(1);
		}
	}
	cout << "Yes" << endl;
	for (int i = 1; i < N; i++) {
		cout << sign[i] + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 10744
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353



n = int(sys.stdin.buffer.readline())
while True:
    if len(Counter(str(n))) == 1:
        print(n)
        break
    n += 1
    


Measured memory_bytes: 15396
#!/usr/bin/env python3
import numpy as np
import bisect
X = int(input())
A = np.cumsum(range(1, 10 ** 5))
if np.any(A == X):
    print(A.tolist().index(X) + 1)
else:
    idx = bisect.bisect_left(A, X)
    print(idx + 1)

Measured memory_bytes: 16808
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define z 2000000000000000000
#define sh 100000
vector<int> v[sh+1];
int mark[sh+1];
int indegree[sh+1];
int dp[sh+1];

void bfs(int root)
{
	// dp[root]=0;
	queue<int> q;
	q.push(root);
	while(!q.empty())
	{
		int node=q.front();
		q.pop();
		for(auto it: v[node])
		{
			dp[it]=max(dp[it],dp[node]+1);
			indegree[it]--;
			if(indegree[it]==0)
				q.push(it);
		}
	}
}
int main()
{
 
	
    
    int n,m,i;
    cin>>n>>m;
    for(i=1;i<=m;i++)
    {
    	int a,b;
    	cin>>a>>b;
    	v[a].pb(b);
    	indegree[b]++;
    }
    vector<int> root;
    for(i=1;i<=n;i++)
    {
    	if(indegree[i]==0)
    		root.pb(i);
    	// cout<<indegree[i]<<" ";
    }
    for(auto it: root)
    	bfs(it);
    // cout<<endl;
    int mx=0;
    for(i=1;i<=n;i++)
    	mx=max(mx,dp[i]);
    cout<<mx;
}

Measured memory_bytes: 6528
#include<iostream>
#include<queue>
#include<vector>
#include<functional>
using namespace std;
typedef long long ll;
ll INF = 1e15;
struct Edge {
	ll to;
	ll cost;
};
using P = pair<ll, ll>;
vector<Edge>G[100005];
ll d[100005];

int main() {
	int r;
	int V;
	int E;
	cin >> V >> E >> r;
	for (int i = 0; i < E; i++) {
		ll s, t, d;
		cin >> s >> t >> d;
		G[s].push_back(Edge{t,d});
	}
	
	priority_queue<P, vector<P>, greater<P>>que;
	
	for (int i = 0; i < V; i++) {
		d[i] = INF;
	}
	d[r] = 0;
	que.push(P(0, r));
	while (que.size()) {
		P p = que.top(); que.pop();
		ll cost = p.first;
		int v = p.second;
		if (d[v] < cost) continue;
		for (int i = 0; i < G[v].size(); i++) {
			Edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
	for (int i = 0; i < V; i++) {
		if (d[i] == 1e15) {
			cout << "INF" << endl;
		}
		else {
			cout << d[i] << endl;
		}
	}
	return 0;
}


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

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	const string s = "JOI";
	int M, N;
	cin >> M >> N;
	vector<string> S(M);
	for (int i = 0; i < M; i++) {
		cin >> S[i];
	}
	vector<string> t(2);
	for (int i = 0; i < 2; i++) {
		cin >> t[i];
	}
	int cnt = 0;
	for (int i = 0; i + 2 <= M; i++) {
		for (int j = 0; j + 2 <= N; j++) {
			bool ok = true;
			for (int x = i; x < i + 2; x++) {
				for (int y = j; y < j + 2; y++) {
					if (S[x][y] != t[x - i][y - j]) {
						ok = false;
					}
				}
			}
			cnt += ok;
		}
	}
	int add = 0;
	for (int i = 0; i < M; i++) {
		for (int j = 0; j < N; j++) {
			for (int k = 0; k < 3; k++) {
				int aa = 0;
				for (int x = max(0, i - 1); x <= min(i, M - 2); x++) {
					for (int y = max(0, j - 1); y <= min(j, N - 2); y++) {
						bool ok = true;
						for (int xx = x; xx < x + 2; xx++) {
							for (int yy = y; yy < y + 2; yy++) {
								if (S[xx][yy] != t[xx - x][yy - y]) {
									ok = false;
								}
							}
						}
						aa -= ok;
					}
				}
				char c = S[i][j];
				S[i][j] = s[k];
				for (int x = max(0, i - 1); x <= min(i, M - 2); x++) {
					for (int y = max(0, j - 1); y <= min(j, N - 2); y++) {
						bool ok = true;
						for (int xx = x; xx < x + 2; xx++) {
							for (int yy = y; yy < y + 2; yy++) {
								if (S[xx][yy] != t[xx - x][yy - y]) {
									ok = false;
								}
							}
						}
						aa += ok;
					}
				}
				S[i][j] = c;
				add = max(add, aa);
			}
		}
	}
	cout << cnt + add << endl;
	return 0;
}



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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
using PII = pair<int, int>;
using VPII = vector<PII>;

int main()
{
  int D, G;  cin >> D >> G;
  VPII Problems(D);
  int p, c;
  REP(i, D) {
    cin >> p >> c;
    Problems[i] = make_pair(p, c);
  }
  
  int ans = -1;
  for(int i=0; i < (1<<D); i++) {
    bitset<10> bs(i);
    int point = 0, pnum = 0;
    REP(j, D) {
      if(bs.test(j)) {
        tie(p, c) = Problems[j];
        point += 100*(j+1)*p + c;
        pnum += p;
      }
    }
    if(point >= G) {
      if(ans == -1 || ans > pnum)
        ans = pnum;
    } else {
      REP(j, D) {
        int pn = D-1-j;
        if(!bs.test(pn)) {
          REP(k, Problems[pn].first) {
            point += 100*(pn+1);
            pnum++;
            if(point >= G) {
              if(ans == -1 || ans > pnum)
                ans = pnum;
            }
          }
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n , w;
	cin >> n >> w;
	vector<ll>dp(w + 1);
	ll nax = 0;
	int weight, value;
	for (int i = 0; i < n; i++) {
		cin >> weight >> value;
		int need = w - weight;
		for (int k = need; k >= 0; k--) {
			dp[k + weight] = max(dp[k + weight], dp[k] + value);
			nax = max(nax, dp[k + weight]);
		}
	}
	cout << nax << endl;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()
#define var(t, ...) t __VA_ARGS__;in,__VA_ARGS__;

void Calc();
int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);
  cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
template<class A>int comp(A a, A b) { return a < b ? 1 : b < a ? -1 : 0; }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/


void Calc() {
  var(int, x, a, b);
  if (abs(x - a) < abs(x - b)) {
    cout << ('A') << endl;
  }
  else {
    cout << ('B') << endl;
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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++)

int main(){
  int N, M; cin >> N >> M;
  vector<int> city(N);
  int a, b;
  rep(i, M){
    cin >> a >> b;
    city[a-1]++; city[b-1]++;
  }
  rep(i, N) cout << city[i] << endl;
}


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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

// dp[x] := xから始まる最長経路の長さ
// dp[x] = max(dp[y] + 1) xから直接辺が伸びている頂点yすべてのmaxを取る

// DAG -> トポロジカルソート
// 漸化式だけ立っている
// 良い順番があることは分かる
// 埋める順番がわからない

vector<int> g[101010];
int memo[101010];
bool done[101010];

int dp(int v) {
    if (done[v]) return memo[v];
    done[v] = true;
    int ans = 0;
    for (int u : g[v]) {
        ans = max(dp(u) + 1, ans);
    }
    return memo[v] = ans;
}

int main() {
    int N, M;
    cin >> N >> M;
    for (int i = 0; i < M; ++i) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
    }
    int ans = 0;
    for (int v=1; v<=N; ++v) {
        ans = max(ans, dp(v));
    }
    cout << ans << endl;
}


Measured memory_bytes: 8320
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int a,b; cin >> a >> b;
    out((1+(b-a))*(b-a)/2-b);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define il inline

namespace io {

#define in(a) a = read()
#define out(a) write(a)
#define outn(a) out(a), putchar('\n')

#define I_int ll
inline I_int read() {
    I_int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-') f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}
char F[200];
inline void write(I_int x) {
    if (x == 0) return (void) (putchar('0'));
    I_int tmp = x > 0 ? x : -x;
    if (x < 0) putchar('-');
    int cnt = 0;
    while (tmp > 0) {
        F[cnt++] = tmp % 10 + '0';
        tmp /= 10;
    }
    while (cnt > 0) putchar(F[--cnt]);
}
#undef I_int

}
using namespace io;

using namespace std;

#define N 100010
const ll mod = 1e9 + 7;
int n = read();
ll f[N][5][5][5];
/*
f[i][j][a][b]位置i，字符j,i-1字符a,i-2字符b

*/
map<int,string>mp;
bool check(int a,int b,int c, int d) {
	
	if(mp[a]+mp[c]+mp[b]=="AGC") return 0;
	if(mp[a]+mp[b]+mp[d]=="AGC") return 0;
	if(mp[a]+mp[c]+mp[d]=="AGC") return 0;
	
	if(mp[b]+mp[c]+mp[d]=="AGC") return 0;
	if(mp[b]+mp[d]+mp[c]=="AGC") return 0;
	
	if(mp[c]+mp[b]+mp[d]=="AGC") return 0;
	
	return 1;
}

int main() {
	if(n<=2) return outn(pow(4,n)), 0;
	mp[0]='Q'; mp[1]='A'; mp[2]='C';mp[3]='G';mp[4]='T';
	f[0][0][0][0]=1;
	 for(int i = 1; i <= n; ++i) {
	 	for(int j = 1; j <= 4; ++j) {
	 		for(int a = 0; a <= 4; ++a) {
	 			for(int b = 0; b <= 4; ++b) {
	 				for(int l = 0; l <= 4; ++l) {
	 					if(check(l,b,a,j)) (f[i][j][a][b] += f[i-1][a][b][l]) %= mod;
					 }
				 }
			 }
		 }
	 }
	 ll ans = 0;
	 for(int i = 1; i <= 4; ++i) {
	 	for(int j = 1; j <= 4; ++j) {
	 		for(int k = 1; k <= 4; ++k) {
	 			(ans+=f[n][i][j][k])%=mod;
			 }
		 }
	 }
	 outn(ans);
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var N = consoleReader.Int;
            var d = consoleReader.Split.Int;
            Array.Sort(d);
            return d[N / 2] - d[N / 2 - 1];
        }

        #region いつもの
        private readonly ConsoleReader consoleReader;
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program(new ConsoleReader()).Calc()); static string AllLines<T>(IEnumerable<T> source) => string.Join("\n", source);
        #endregion
    }

#pragma warning disable
    public class ConsoleReader { public class SplitLine { string[] splited; public SplitLine(string line) { splited = line.Split(); } public string[] String => splited.ToArray(); public int[] Int => splited.Select(int.Parse).ToArray(); public long[] Long => splited.Select(long.Parse).ToArray(); public ulong[] ULong => splited.Select(ulong.Parse).ToArray(); public double[] Double => splited.Select(double.Parse).ToArray(); } public class RepeatLine { ConsoleReader reader; int num; public RepeatLine(ConsoleReader reader, int num) { this.reader = reader; this.num = num; } public IEnumerable<string> String { get { for (int i = 0; i < num; i++) yield return reader.String; } } public IEnumerable<int> Int { get { for (int i = 0; i < num; i++) yield return reader.Int; } } public IEnumerable<long> Long { get { for (int i = 0; i < num; i++) yield return reader.Long; } } public IEnumerable<string[]> SplitString { get { for (int i = 0; i < num; i++) yield return reader.Split.String; } } public IEnumerable<int[]> SplitInt { get { for (int i = 0; i < num; i++) yield return reader.Split.Int; } } } public virtual string String => Console.ReadLine(); public int Int => int.Parse(String); public long Long => long.Parse(String); public ulong ULong => ulong.Parse(String); public double Double => double.Parse(String); public SplitLine Split => new SplitLine(String); public RepeatLine Repeat(int count) => new RepeatLine(this, count); }
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/03/03  Problem: code-festival-2017-qual-b_c / Link: https://code-festival-2017-qualb.contest.atcoder.jp/tasks/code_festival_2017_qualb_c?lang=en  ----- */
/* ------問題------

りんごさんは N 頂点 の連結な無向グラフを持っています。 このグラフにはすでに M 本の辺があり、i 本目の辺は頂点 Ai と頂点 Bi を繋いでいます。
りんごさんは以下の操作を行うことで、辺を追加しようと思っています。
操作：頂点 u から辺をちょうど 3 本辿ることによって頂点 v に辿り着けるような u,v(u≠v) をとり、頂点 u と頂点 v の間に辺を追加する。ただし、すでに頂点 u と頂点 v の間に辺が存在する場合は辺を追加することはできない。
りんごさんが追加できる辺の本数の最大値を求めて下さい。

-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N, M;

LL ans = 0LL;
LL black = 0;
void dfs(int v, int p, VI &color, int c, VVI &G) {
	color[v] = c;
	if (c == 0)black++;
	FOR(i, 0, SZ(G[v])) {
		int nx = G[v][i];
		if (color[nx] != -1) {
			if (color[nx] == c)ans = 0;
		}
		else {
			dfs(nx, v, color, !c, G);
		}
	}
}

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

	cin >> N >> M;
	VVI G(N);
	FOR(i, 0, M) {
		int a, b; cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	VI color(N, -1);
	ans = 1;
	dfs(0, -1, color, 0, G);
	if (ans) { // 二部グラフ
		ans = 0;
		// O(V+E)

		int white = N -  black;
		FOR(i, 0, N) {

			int ret = 0;
			if (color[i] == 1) {// white
				ans += black - SZ(G[i]);
			}
			else {
				ans += white - (SZ(G[i]));
			}
		}
		ans /= 2;

	}
	else {// ではない
		ans = 0;
		FOR(i, 0, N) {
			ans += (N - 1) - SZ(G[i]);
		}
		ans /= 2;
	}
	cout << ans << "\n";

	return 0;
}


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

int main(){
 int x;
 int y;
 int z;
 int a;
 int b;
 cin>>x>>y>>z>>a>>b;

 int p = x+a-50;
 int q = x+b-50;
 int r = y+a-50;
 int s = y+b-50;
 int t = z+a-50;
 int u = z+b-50;
   int k[6]={p,q,r,s,t,u};
    int mn=k[0];
   for(int i=0;i<6;i++){
    mn = min(mn,k[i]);
   }
 cout<<mn<<endl;
 return 0;
}



Measured memory_bytes: 3064
#include<queue>
#include<cstdio>

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

using namespace std;

const int INF=1<<29;

template<class T>
struct AdjMatrix:public vector< vector<T> >{
	AdjMatrix(int n,const vector<T> &v=vector<T>()):vector< vector<T> >(n,v){}
};

template<class T>
T augment(const AdjMatrix<T> &capa,int src,int snk,AdjMatrix<T> &flow){
	int n=capa.size();
	vector<int> parent(n,-1); parent[src]=-2;

	T water=0;
	queue< pair<T,int> > qu; qu.push(make_pair(INF,src));
	while(!qu.empty()){
		pair<T,int> a=qu.front(); qu.pop();
		int u=a.second;
		T w=a.first;
		if(u==snk){ water=w; break; }
		rep(v,n) if(parent[v]==-1 && capa[u][v]-flow[u][v]>0) {
			qu.push(make_pair(min(w,capa[u][v]-flow[u][v]),v));
			parent[v]=u;
		}
	}

	if(water==0) return 0;

	for(int v=snk,u=parent[snk];v!=src;v=u,u=parent[u]){
		flow[u][v]+=water;
		flow[v][u]-=water;
	}

	return water;
}

template<class T>
T FordFulkerson(const AdjMatrix<T> &capa,int src,int snk){
	int n=capa.size();
	AdjMatrix<T> flow(n,vector<T>(n));

	T ans=0;
	while(1){
		T water=augment(capa,src,snk,flow);
		if(water==0) break;
		ans+=water;
	}
	return ans;
}

int main(){
	for(int n,m;scanf("%d%d",&n,&m),n;){
		int ans=0;
		AdjMatrix<int> adj(n,vector<int>(n));
		rep(i,m){
			int u,v,w; scanf("%d%d%d",&u,&v,&w);
			if(w<0) ans+=w;
			adj[u][v]=adj[v][u]=max(w,0);
		}

		int ans2=INF;
		rep(v,n) if(v!=0) ans2=min(ans2,FordFulkerson(adj,0,v));
		printf("%d\n",ans+ans2);
	}

	return 0;
}

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

int main()
{
	int w, n, z;
	char c[30];
	int N[30];
	int a[30], b[30];
	cin >> w >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i] >> c[i] >> b[i];
	}
	for (int i = 1; i <= w; i++)
	{
		N[i] = i;
	}
	for (int i = 0; i < n; i++)
	{
		z = N[a[i]];
		N[a[i]] = N[b[i]];
		N[b[i]] = z;
	}
	for (int i = 1; i <= w; i++)
	{
		cout << N[i] << endl;
	}
}


Measured memory_bytes: 3004
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

ll mod = 1e9+7 ;
const ld error = 1e-8;
const ld PI = acosl(-1); //const ld PI = acosl(-1)

#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define eq(x, y) (fabs((x)-(y))<error)
#define bt(i) (1LL<<(i))

#define debug(x) cerr<<#x<<" = "<<(x)<<"\n"
#define hoise cerr<<"hoise - "<<__LINE__<<"\n"
#define tham getchar()
//mt19937 rng((unsigned)chrono::system_clock::now().time_since_epoch().count()); //mt199937_64 for ll
//mt19937 rng(199);

inline ll MOD(ll x, ll m = mod){
    ll y = x % m;
    return (y >= 0) ? y: y+m;
}

const int inf = 1e9;
const ll infl = 1e18+1;
const int nmax = 100 + 10;
///===========================================  template  =======================================================

ll dp[nmax][nmax];

void solve2(int n, int d, int c){
    if(c == 1) return;
    if(d > 0){
        if(dp[d-1][c-1] >= n){
            cout<<d-1;
            solve2(n, d-1, c-1);
            return;
        }
        else n -= dp[d-1][c-1];
    }

    if(dp[d][c-1] >= n){
        cout<<d;
        solve2(n, d, c-1);
        return;
    }
    else n -= dp[d][c-1];

    cout<<d+1;
    solve2(n, d+1, c-1);
}

void solve(int n){
    if(n == 0) return;
    for(int i = 1; i<=12; i++){
        for(int j = 1; j<=9; j++){
            if(dp[j][i] < n){
                n-=dp[j][i];
            }
            else{
                cout<<j;
                solve2(n, j, i);
                return;
            }
        }
    }
}


int main(){
    FASTIO;
    int n;
    cin>>n;
    for(int i = 0; i<=9; i++) dp[i][1] = 1;

    for(int i = 2; i<=12; i++){
        for(int j = 0; j<=9; j++){
            if(j > 0) dp[j][i] += dp[j-1][i-1];
            dp[j][i] += dp[j][i-1];
            if(j < 9) dp[j][i] += dp[j+1][i-1];
        }
    }

    solve(n);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N ;
    cin >> N;
    if (N == 1){
        cout << "Hello World" << endl;
    }else{
        int A, B;
        cin >> A >> B;
        cout << A + B << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#define INF 10000000
using namespace std;

int f(int x){
  if(x % 2 == 0){
    return x / 2;
  }

  return 3*x + 1;

}

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

  vector<int> a(INF);
  int min = INF;
  for(int i = 1; ; i++){
    if(i == 1) a[i] = s;

    else{
      a[i] = f(a[i-1]);

      for(int j = 1; j < i; j++){
        if(a[i] == a[j] && min > i){
          min = i;
          break;
        }
      }

      if(min != INF) break;
    }
  }

  cout << min << endl;

  return 0;

}

Measured memory_bytes: 39296
#include <iostream>
#include <cstdio>
#include <algorithm>

#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

int main() {
    double r;
    cin >> r;
    double pi = M_PI;
    double l = 2 * r * pi;
    double S = r * r * pi;
    printf("%.9f %.9f", S, l);
}


Measured memory_bytes: 3208
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

T = input()

c = Counter(T)
h = c["?"]
d = c["D"] + h
B = ""
for t in T:
    if t == "?":
        B += "D"
    else:
        B += t
print(B)


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

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int A,B;
  cin >> A >> B;
  cout << max({A+B,A-B,A*B}) << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
lst = [0]*n
for i in range(n):
    s = input()
    lst[i] = s

lst_af = sorted(lst)

word = lst_af[0]
most_lst = []
most_lst.append(word)
max_num = 1
cnt = 1

for i in range(1, n):
    now_word = lst_af[i]
    if now_word == word:
        cnt += 1
    else:
        cnt = 1
    if max_num == cnt:
        most_lst.append(now_word)
    if max_num < cnt:
        most_lst = []
        most_lst.append(now_word)
        max_num = cnt
    word = now_word

for x in most_lst:
    print(x)

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

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

Measured memory_bytes: 256
N,M=map(int,input().split())
S="0"+input()
E=[[] for i in range(N+1)]
AOUT=[0]*(N+1)
BOUT=[0]*(N+1)

for i in range(M):
    x,y=map(int,input().split())
    E[x].append(y)
    E[y].append(x)

    if S[x]=="A":
        AOUT[y]+=1
    else:
        BOUT[y]+=1

    if S[y]=="A":
        AOUT[x]+=1
    else:
        BOUT[x]+=1

from collections import deque
Q=deque()

USE=[0]*(N+1)

for i in range(N+1):
    if AOUT[i]==0 or BOUT[i]==0:
        Q.append(i)
        USE[i]=1

while Q:
    x=Q.pop()

    for to in E[x]:
        if USE[to]==0:
            if S[x]=="A":
                AOUT[to]-=1
            else:
                BOUT[to]-=1

            if AOUT[to]==0 or BOUT[to]==0:
                Q.append(to)
                USE[to]=1

if 0 in USE:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 46192
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)

	length := len(s)

	for i := 0; i < length - 2; i++ {
		if s[i] == s[i+2] {
			fmt.Printf("%d %d\n", i + 1, i + 3)
			return
		}
		if s[i] == s[i+1] {
			fmt.Printf("%d %d\n", i + 1, i + 2)
			return
		}
	}
	if s[length - 2] == s[length - 1] {
		fmt.Printf("%d %d", length - 1, length)
	} else {
		fmt.Println("-1 -1")
	}
}


Measured memory_bytes: 2580
#include <cstdio>
#include <math.h>
using namespace std;
int main(){
		int N,K;
		scanf("%d %d",&N,&K);
		int s[N];
		for(int i=0; i<N ;i++){
			scanf("%d",&s[i]);
		}
		int min;
		for(int i=0;i<N-K+1;i++){
				int d;
				d=fmin(fabs(s[i]),fabs(s[K+i-1]))+fabs(s[K+i-1]-s[i]);
				min = fmin(min,d);
				if(i==0)min=d;
		}
		printf("%d\n", min);
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
#define LLI long long int
#define ULTRA 2134567890
#define de(x) if(x!=0 && MODE==x)
#define MODE 1
using namespace std;

int arr[200007];
bool b[200007];

int main()
{
    int i,j;
    int N;

    scanf("%d", &N);

    int cnt = 0;
    for( i=1; i<=N; i++)
    {
        scanf("%d", &arr[i]);
    }

    vector<int> keep;
    for( i=N; i>=1; i--)
    {
        if( b[i] != arr[i])
        {
            for( j=1; j*j<=i; j++)
            {
                if(i%j==0)
                {
                    b[j] ^= 1;
                    if( j*j!=i)
                        b[i/j] ^= 1;
                }
            }
            keep.push_back(i);
        }
    }

    printf("%d\n", keep.size());
    for( auto it:keep)
    {
        printf("%d ", it);
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 2552
#include <bits/stdc++.h>
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define mod 1000000007

using namespace std;

//ll cnt;

int main()
{
	IOS;
	int r,g,b,n;
    cin>>r>>g>>b>>n;
    int cnt=0;
    for(int y=0;y<=n/r;y++)
    {
        for(int x=0;x<=n/g;x++)
            {
                if(y*r+x*g==n)
                    cnt++;
                else if((n-y*r-x*g)%b==0 && n-y*r-x*g>0)
                        cnt++;
            }
    }
    cout<<cnt<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<int>;
using A = array<int, 2>;
using P = pair<int, int>;
constexpr int MOD{1000000000 + 7};
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
constexpr array<int, 4> dx{1, 0, -1, 0}, dy{0, 1, 0, -1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
constexpr int div_roundup(int a, int b)
{
    return (a + b - 1) / b;
}

// vector<vector<int>> vec(n_rows, vector<int>(n_cols, value));

// *****************************************************************************

void solve()
{
    int n;
    cin >> n;
    V p(n);

    int wrong = 0;
    for (int i = 0; i < n; i++)
    {
        int input;
        cin >> input;
        if (input != (i + 1))
            wrong++;
    }

    if (wrong == 0 || wrong == 2)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}

// *****************************************************************************

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

    solve();
}


Measured memory_bytes: 256