akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int  n,m,i,j,k,l;
    char  c[345];
    scanf("%d %s",&n,&c);
    if(n%2==1)
        printf("No");
    else{
        m=n/2;
        for(i=0;i<n/2;i++){
            if(c[i]!=c[m+i]){
                printf("No");
                return 0;
            }
        }
        printf("Yes");
    }
}


Measured memory_bytes: 256
h, w, f = list(map(int, input().split()))
c = [input() for i in range(h)]
count = 0
bit_h = []
for k in range(2**h):
    hh = []
    for l in range(h):
        if((k >> l) & 1):
            hh.append(1)
        else:
            hh.append(0)
    bit_h.append(hh)

bit_w = []
for i in range(2**w):
    ww = []
    for j in range(w):
        if((i >> j) & 1):
            ww.append(1)
        else:
            ww.append(0)
    bit_w.append(ww)

ans = 0
for i in range(len(bit_h)):
    for j in range(len(bit_w)):
        count = 0
        for k in range(h):
            for l in range(w):
                if bit_h[i][k] == 1 and bit_w[j][l] == 1 and c[k][l] == "#":
                    count += 1
        if count == f:
            ans += 1
print(ans)


Measured memory_bytes: 9184
import bisect

n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n - 1):
  a[i] -= 1
  a[i + 1] += a[i]
a[n - 1] -= 1

memo = {0 : []}
for i in range(n):
  if a[i] % k not in memo.keys():
    memo[a[i] % k] = [i]
  else:
    memo[a[i] % k].append(i)

ans = bisect.bisect_left(memo[0], k - 1)

for i in memo.keys():
  for j in range(len(memo[i]) - 1):
    ans += bisect.bisect_left(memo[i], memo[i][j] + k) - 1 - j

print(ans)

Measured memory_bytes: 57108
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const int MAX_N = 105;
const int MAX_W = 300;
ll w[MAX_N],v[MAX_N],dp[MAX_N][MAX_W];
vector<ll> w0,w1,w2,w3;

int main()
{
	int N,W;
	cin >> N >> W;
	rep(i,N)
	{
		cin >> w[i] >> v[i];
	}
	w0.push_back(v[0]);
	rep(i,N-1)
	{
		if (w[i+1] == w[0]) w0.push_back(v[i+1]); 
		if (w[i+1] == w[0] + 1) w1.push_back(v[i+1]); 
		if (w[i+1] == w[0] + 2) w2.push_back(v[i+1]); 
		if (w[i+1] == w[0] + 3) w3.push_back(v[i+1]); 
	}
	sort(w0.begin(), w0.end()); reverse(w0.begin(), w0.end());
	sort(w1.begin(), w1.end()); reverse(w1.begin(), w1.end());
	sort(w2.begin(), w2.end()); reverse(w2.begin(), w2.end());
	sort(w3.begin(), w3.end()); reverse(w3.begin(), w3.end());
	ll ans = 0;
	rep(i,w0.size()+1)
	{
		rep(j,w1.size()+1)
		{
			rep(k,w2.size()+1)
			{
				rep(l,w3.size()+1)
				{
					ll wtot = w[0]*i + (w[0]+1)*j + (w[0]+2)*k + (w[0]+3)*l;
					if (wtot <= W)
					{
						ll vtot = 0;
						rep(m,i) vtot += w0[m];
						rep(m,j) vtot += w1[m];
						rep(m,k) vtot += w2[m];
						rep(m,l) vtot += w3[m];						
						ans = max(ans,vtot);
					}
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define INF 1000000001
ll gcd(ll a, ll b){
    if (a%b == 0) return(b);
    else return(gcd(b, a%b));
}
 
ll lcm(ll a, ll b){
    return a * b / gcd(a, b);
}

vector<pair<ll, ll> > prime_factorize(ll N) {
    vector<pair<ll, ll> > res;
    for (ll a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        ll ex = 0; // 指数
        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        // その結果を push
        res.push_back({a, ex});
    }
    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}
/* vector<pair<ll,ll>>で受け取る！
例えば360=2^3*3^2*5は
{{2,3},{3,2},{5,1}}*/

int main() {
    
    ll a,b;cin >> a >> b;
    ll x=gcd(a,b);
    vector<pair<ll,ll>> y=prime_factorize(x);
    cout << y.size()+1 << endl;

    return 0;
}

Measured memory_bytes: 3632
def solve():
  n= int(input())
  a = list(int(i) for i in input().split())
  ct = 0
  flag = 0
  for i in range(n-1):    
   if a[i+1] > a[i]:
    if flag == -1:
      ct+= 1
      flag = 0
    else:
      flag = 1
   elif a[i+1] < a[i]:
    if flag == 1:
      ct+= 1
      flag = 0
    else:
      flag = -1 
  return ct+1
  
  
if __name__ == '__main__':
  print(solve())

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

#define rep(i, s, n) for(int i = s; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    ll x;
    cin >> x;
    ll a, b, c;
    a = x / 500;
    x -= a * 500;
    b = x / 5;
    cout << a * 1000 + b * 5  << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int arr[1000000000];
int seed[100];
int cnt = 0;

void insertion_sort(int* arr, int len, int g)
{
	for (int i = g; i < len; i++)
	{
		int tmp = arr[i], j = i - g;
		while (j >= 0 && arr[j] > tmp)
		{
			arr[j+g] = arr[j];
			j = j - g;
			cnt++;
		}
		arr[j+g] = tmp;
	}
}

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

	int power = 1, seed_count = 0;
	while (power <= len)
	{
		seed[seed_count++] = power;
		// printf("%d\n", seed[seed_count-1]);
		power = 2*power;
	}
	printf("%d\n", seed_count);

	for (int i = 0; i < seed_count; i++)
	{
		printf("%d ", seed[seed_count-i-1]);
		insertion_sort(arr, len, seed[seed_count-i-1]);
	}
	printf("\n");
	printf("%d\n", cnt);


	for (int i = 0; i < len; i++)
	{
		printf("%d\n", arr[i]);
	}

	return 0;
}



Measured memory_bytes: 5636
#include <bits/stdc++.h>
#include <iostream>
#include <vector>

int main() {
    int N, M;

    std::cin >> N;
    std::vector<std::string> blues(N);
    for (int i{0}; i < N; i++)
        std::cin >> blues.at(i);

    std::cin >> M;
    std::vector<std::string> reds(M);
    for (int i{0}; i < M; i++)
        std::cin >> reds.at(i);

    int max{0};

    for(const auto &text : blues) {
        int ret{0};
        for (const auto &check : blues) {
            if (text == check)
                ret++;
        }
        for (const auto &minus : reds) {
            if (text == minus)
                ret--;
        }

        if (ret > max)
            max = ret;
    }

    std::cout << max;
}



Measured memory_bytes: 256
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 //??\?????\??´?????£??????????????\?°¨?????°??????map?????¨??????????????°??? 
 
 int main()
 {
   int N;
   int start,end;
   while(cin>>N>>start>>end)
   {
     bool arr[2000]={false};
     //map<int,int> mm;
     //map<int,int>::iterator iter;
     //map<int,int>::iterator iter2;
     if(N==0&&start==0&&end==0) break;
     start=(start/100)*60+(start%100);
     end=(end/100)*60+(end%100);
     for(int i=0;i<N;i++)
     {
       int kk;
       int temp;
       cin>>kk;
       int a,b;
       for(int j=0;j<kk;j++)
       {
         cin>>a>>b;
         a=(a/100)*60+(a%100);
         b=(b/100)*60+(b%100);
         if(j==0)
         {
           //if(a>start) mm[start]=a;
           if(a>start) for(int k=start;k<a;k++) arr[k]=true;            
         }
         else
         {
           for(int k=temp;k<a;k++) arr[k]=true; 
           //mm[temp]=a;        
         }        
         temp=b;
       }
       if(end>temp)
       { 
         for(int k=temp;k<end;k++) arr[k]=true;
         //mm[temp]=end;
       }
     }
     /*
     for(iter2=mm.begin();iter2!=mm.end();++iter2)
     {
       cout<<iter2->first<<" "<<iter2->second<<endl;                                             
     }
     */
     int max=0;
     int duration=0;
     for(int i=start;i<(end+1);i++)
     {
       if(arr[i]) duration++;
       else
       {
         if(duration>max) max=duration;
         duration=0;    
       }
       //cout<<duration<<endl;            
     }
     cout<<max<<endl;
     /*
     iter=mm.begin();
     int start2=iter->first; 
     int end2=iter->second;
     int max=end2-start2;
     iter++;
     for(;iter!=mm.end();++iter)
     {
       int p=iter->first;
       int q=iter->second;
       if(p<=end2&&q>=end2) end2=q;
       else if(p>end2)
       { 
         start2=p;
         end2=q;
       }
       int dur=end2-start2;
       if(dur>max) max=dur;                                  
     }
     cout<<max<<endl;
   }
   */
   }
   //while(1);
   return 0;
 }

 
  

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

#define pi acos(-1.0)

int main() {
    int x,y;
    string s;
    while(1) {
        cin >> x >> s >> y;
        if(s=="?") break;
        if(s=="+") cout << x+y << endl;
        else if(s=="-") cout << x-y << endl;
        else if(s=="*") cout << x*y << endl;
        else if(s=="/") cout << x/y << endl;
    }

    return 0;
}



Measured memory_bytes: 3164
X = int(input())
flag = -1
i1 = 0
j1 = 0
for i in range(1000):
    for j in range(-1000, 1000):
        if i ** 5 - j ** 5 == X:
            flag = 0
            i1 = i
            j1 = j
            break
    if flag == 0:
        break
print(i1, j1)

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

typedef long long LL;
LL a, b, c, d, e, f, ansx, ansy, tmpx, tmpy;

int main()
{
	scanf("%lld %lld", &a, &b);
	scanf("%lld %lld", &c, &d);
	scanf("%lld %lld", &e, &f);
	a *= 100, b *= 100;
	for(int i = 0; i <= f; i += a)
	for(int j = 0; i + j <= f; j += b)
	for(int k = 0; i + j + k <= f; k += c)
	for(int l = 0; i + j + k + l <= f; l += d)
	{
		tmpx = i + j;
		tmpy = k + l;
		if(tmpy * 100 > tmpx * e) continue;
		if(tmpx + tmpy == 0) continue;
		if(ansy == 0){
			ansx = tmpx, ansy = tmpy;
		}else if(ansy * (tmpx + tmpy) < tmpy * (ansx + ansy)){
			ansx = tmpx, ansy = tmpy;
		}
	}
	printf("%lld %lld\n", ansx + ansy, ansy);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100


int F[MAX];

int main(){

  int i,n;

  scanf("%d",&n);

  /*for( i = 0 ; i < n ; i++ ){
    F[i] = -1;
    }*/

  F[0] = 1;
  F[1] = 1;

  for( i = 2 ; i <= n ; i++ ){
    F[i] = F[i-2] + F[i-1];
  }
 
  printf("%d\n",F[n]);

  return 0;
}

Measured memory_bytes: 596
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

internal static class CR
{
    public static string Get() { return Console.ReadLine(); }
    public static IEnumerable<string> GetTexts() { return Console.ReadLine().Split(' '); }
    public static int GetInteger() { return int.Parse(Console.ReadLine()); }
    public static IEnumerable<long> GetIntegers() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)); }
}

namespace AtCoder.F
{
    public class Program
    {
        public static long N { get; private set; }
        public static long D { get; private set; }
        public static long A { get; private set; }

        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var inputs = CR.GetIntegers().ToList();
            N = inputs[0];
            D = inputs[1];
            A = inputs[2];
            var monsters = new List<Monster>();
            for (int i = 0; i < N; i++)
            {
                inputs = CR.GetIntegers().ToList();
                monsters.Add(new Monster { X = inputs[0], H = inputs[1] });
            }

            monsters = monsters.OrderBy(x => x.X).ToList();
            var attackCountSum = 0L;
            var damageSum = 0L;
            var checkStartIndex = 0;
            var attackInfo = new List<AttackInfo>();
            for (int i = 0; i < N; i++)
            {
                var startMonster = monsters[i];

                // 届いていない攻撃のダメージを減算する
                for (int j = checkStartIndex; j < attackInfo.Count; j++)
                {
                    var atk = attackInfo[j];
                    if (startMonster.X > atk.MaxX)
                    {
                        damageSum -= atk.Damage;

                        // 端まで判定しきってしまった場合
                        if (j + 1 == attackInfo.Count)
                        {
                            checkStartIndex = j + 1;
                            break;
                        }
                    }
                    else
                    {
                        checkStartIndex = j;
                        break;
                    }
                }

                if (monsters[i].H <= damageSum) continue;

                var count = (long)Math.Ceiling((double)(startMonster.H - damageSum) / A);
                attackCountSum += count;

                attackInfo.Add(new AttackInfo { Damage = count * A, MaxX = startMonster.X + 2 * D });
                damageSum += count * A;
            }

            return attackCountSum;
        }
    }

    internal class AttackInfo
    {
        public long Damage { get; set; }
        public long MaxX { get; set; }
    }

    class Monster
    {
        public long X { get; set; }
        public long H { get; set; }
    }
}


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

int main() {
  int N;
  cin >> N;
  string S;
  int ac, wa, tle, re;
  ac = 0;
  wa = 0;
  tle = 0;
  re = 0;
  for (int i = 0; i < N; i++) {
    cin >> S;
    if (S == "AC") {
      ac++;
    } else if (S == "WA") {
      wa++;
    } else if (S == "TLE") {
      tle++;
    } else {
      re++;
    }
  }
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;

}

Measured memory_bytes: 3624
#!/usr/local/bin/ruby

a,b= gets.split.map(&:to_i)

# puts (a/b).to_s+" "+(a%b).to_s+" "+(a/b.to_f).to_s
puts sprintf("%5.100f %5.100f %5.100f", (a/b), (a%b) , (a/b.to_f))

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

namespace ConsoleApp15
{
    class Class132
    {
        static void Main()
        {
            string ABCD = Console.ReadLine();
            int ans = -1;
            for(int i = 0; i < (1 << ABCD.Length - 1); i++)
            {
                int sum = int.Parse(ABCD[0].ToString());
                for(int j = 1; j < ABCD.Length; j++)
                {
                    if ((i & (1 << j - 1)) > 0)
                    {
                        sum += int.Parse(ABCD[j].ToString());
                    }
                    else
                    {
                        sum -= int.Parse(ABCD[j].ToString());
                    }
                }
                if (sum == 7)
                {
                    ans = i;break;
                }
            }
            if (ans >= 0)
            {
                string show = ABCD[0].ToString();
                for(int i = 0; i < ABCD.Length - 1; i++)
                {
                    if ((ans & (1 << i)) > 0) show += "+";
                    else show += "-";
                    show += ABCD[i + 1];
                }
                show += "=7";
                Console.WriteLine(show);
            }
        }
    }
}


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

int main()
{
  int N,K;
  cin >> N >> K;
  int A[N];
  int onepos = 10000;
  int ans = 0;
  for(int i = 0; i <N;i++)
  {
    cin>>A[i];
    if(A[i] == 1)onepos = i;
  }

  if(((N-K)/(K-1))%K == 0 && N){

  }
  if(N != K)ans += 1 + (N-K)/(K-1);
  else {
    printf("1\n");
    return 0;
  }

  if((N-K)%(K-1) != 0)ans++;

  printf("%i\n",ans);

  // while(true)
  // {
  //
  // }
  return 0;
}


Measured memory_bytes: 640
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let n=read::<usize>();
    let mut c=vec![0;n+1];
    c[0]=3;
    let mut ans=1u64;
    let m=1000000007;
    for _ in 0..n{
        let a=read::<usize>();
        ans=ans*c[a]%m;
        c[a]-=1;
        c[a+1]+=1;
    }
    println!("{}",ans);
}


Measured memory_bytes: 4352
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::Read;
#[allow(dead_code)]
fn getline() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok().unwrap();
    ret
}
fn get_word() -> String {
    let mut stdin = std::io::stdin();
    let mut u8b: [u8; 1] = [0];
    loop {
        let mut buf: Vec<u8> = Vec::with_capacity(16);
        loop {
            let res = stdin.read(&mut u8b);
            if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        if buf.len() >= 1 {
            let ret = String::from_utf8(buf).unwrap();
            return ret;
        }
    }
}

#[allow(dead_code)]
fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() }

fn solve() {
    let n = get();
    let l: i64 = get();
    let t: i64 = get();
    let mut x = vec![0i64; n];
    let mut w = vec![0i64; n];
    for i in 0 .. n {
        x[i] = get();
        w[i] = if get::<usize>() == 2 { -1 } else { 1 };
    }
    let mut flipped = false;
    if w[0] == -1 {
        for i in 0 .. n {
            w[i] = -w[i];
            x[i] = (l - x[i]) % l;
        }
        flipped = true;
    }
    assert_eq!(w[0], 1);
    let mut enc = 0; // #encounters
    for i in 1 .. n {
        if w[i] == -1 {
            enc += 2 * t / l;
            if (2 * t) % l >= (x[i] - x[0] + l) % l {
                enc += 1;
            }
        }
    }
    let mut pool = Vec::new();
    for i in 0 .. n {
        let nova = (x[i] + w[i] * (t % l) + l) % l;
        pool.push((nova, w[i])); // -1 comes first
    }
    pool.sort();
    // Where did Ant enc fall?
    enc %= n as i64;
    let t = ((x[0] + w[0] * (t % l) + l) % l, w[0]);
    let mut idx = 0;
    while idx < n {
        if pool[idx] == t {
            break;
        }
        idx += 1;
    }
    assert!(idx < n);
    // enc -> idx
    for i in 0 .. n {
        let target = if flipped {
            (n - i + idx + n - enc as usize) % n
        } else {
            (i + idx + n - enc as usize) % n
        };
        let mut x = pool[target].0;
        if flipped {
            x = (l - x) % l;
        }
        println!("{}", x);
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 15612
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
using namespace std;
int main(){
	string s;
	cin>>s;
	int c=0;
	for(int i=0;i<6;i++)if(s[i]=='1')c++;
	cout<<c<<endl;
	return 0;
}


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

#define foreach(i,v) for(auto&& i: v)
#define all(x) (x).begin(), (x).end()

typedef std::vector< std::string > VS;
typedef std::vector<int> VI;
typedef long long ll;

template <class C> C& mini(C& a, C b) { if (b < a) a = b; return a; }
template <class C> C& maxi(C& a, C b) { if (a < b) a = b; return a; }

using namespace std;

template <typename T> void read(T& x) { x.read(); }
template <typename T> void read(vector<T>& v) { for (T& x: v) read(x); }
template <typename X, typename Y> void read(pair<X, Y>& p) { read(p.first); read(p.second); }
template <> void read(int& x) { scanf("%d", &x); }
template <> void read(unsigned int& x) { scanf("%u", &x); }
template <> void read(long long& x) { scanf("%lld", &x); }
template <> void read(unsigned long long& x) { scanf("%llu", &x); }
template <typename T> void read(int& N, vector<T>& v) { read(N); v.resize(N); read(v); }

int N, K, Q;

struct Segment {
	int r, l;
	mutable int gen;
	mutable int cnt;

	Segment(int l, int r) : l(l), r(r), gen(-1), cnt(0) { }

	int Count(int gen) const {
		if (gen != this->gen) {
			this->gen = gen;
			this->cnt = r - l;
		}
		return cnt;
	}

	bool Good() {
		return l < r;
	}
};

bool operator < (const Segment& l, const Segment& r) {
	return l.r < r.r;
}

set<Segment> s;
vector<pair<int, int>> pA;

int solve(int left) {
	int q = Q;
	Segment t(0, N);
	for (int i = left; i < N; i++) {
		t.r = pA[i].second;
		auto it = s.upper_bound(t);
		if (it->Count(left) >= K) {
			it->cnt--;
			if (!--q) {
				return pA[i].first - pA[left].first;
			}
		}
	}
	return INT_MAX;
}

int main(int argc, const char* argv[]) {
	read(N);
	read(K);
	read(Q);
	VI A(N);
	read(A);
	pA.resize(N);
	for (int i = 0; i < N; i++)
		pA[i] = {A[i], i};
	sort(all(pA));
	s.emplace(0, N);
	int ret = INT_MAX;
	for (int l = 0; l <= N - Q; l++) {
		mini(ret, solve(l));
		int splitter = pA[l].second;
		auto it = s.upper_bound(Segment(0, splitter));
		Segment left(it->l, splitter);
		Segment right(splitter+1, it->r);
		s.erase(it);
		if (left.Good())
			s.insert(left);
		if (right.Good())
			s.insert(right);
	}
	printf("%d\n", ret);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<set>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<queue>
#define mem(x) memset(x,0,sizeof(x)) 
#define sca(x) scanf("%d",&x)
#define scaa(x,y) scanf("%d%d",&x,&y)
#define prt(x) printf("%d\n",x)
#define inf 0x7f7f7f7f
#define io ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#pragma GCC optimize(2)
using namespace std;
const double pi=acos(-1); 
const double eps=1e-2;
typedef pair<long,long> pll;
typedef pair<int,int> pii;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<string,string> pcc;
ll a[205];
int main()
{
	ll n,ans=1000,cnt=0;
	cin>>n;
	for(int i=0;i<n;i++)
	cin>>a[i];
	int s=0,x=0;
	a[n]=0;
	for(int i=0;i<n;i++)
	{
		if(a[i]<a[i+1])
		{
			if(x==1)
			x=0;
			if(s==0)
			{
				s=1;
				cnt+=ans/a[i];
				ans-=cnt*a[i];
			}
		}
		else if(a[i]>a[i+1])
		{
			if(s==1)
			s=0;
			if(x==0)
			{
				x=1;
				ans+=cnt*a[i];
				cnt=0;
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3536
#include <iostream>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int r, g, b;
  cin >> r >> g >> b;
  cout << (((g * 10 + b) % 4 == 0) ? "YES" : "NO") << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;
using ll = long long;
using ull = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()		// begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)					// repeat
#define repr(i, begin, end) for (ll i = begin - 1; end <= i; i--)		// repeat reverse

std::chrono::system_clock::time_point  start;

void TimeStart(void)
{
	start = std::chrono::system_clock::now();
}

void TimeEnd(void)
{
	auto time = std::chrono::system_clock::now() - start;
	auto msec = std::chrono::duration_cast<std::chrono::milliseconds>(time).count();
	cerr << endl << msec << " msec " << endl;
}

#endif


int main(void)
{
	vector<ll> t(3);
	cin >> t[0] >> t[1] >> t[2];

	sort(all(t));

	cout << t[0] + t[1];



	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {
	static int MAX = 10000;
	static char[][] map;
	static int H;
	static int W;
	static int[][] d = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		PrintWriter pw=new PrintWriter(System.out);
		H = sc.nextInt(); W = sc.nextInt();
		int black = 0;
		map = new char[H][W];
		int[][] cost = new int[H][W];
		for(int i=0; i<H; i++) {
			String s = sc.next();
			for(int j=0; j<W; j++) {
				map[i][j] = s.charAt(j);
				if(map[i][j] == '#') black++;
			}
		}
		ArrayDeque<Pair> q = new ArrayDeque<>();
		q.add(new Pair(0, 0));
		while(!q.isEmpty()) {
			Pair tmp = q.poll();
			int ch = tmp.h;
			int cw = tmp.w;
			if(ch == H-1 && cw == W-1) break;
			for(int i=0; i<4; i++) {
				int nh = ch + d[i][0];
				int nw = cw + d[i][1];
				if((nh!=0 || nw!=0)&& 0<=nh && nh < H && 0 <= nw && nw < W && map[nh][nw]=='.' && cost[nh][nw] == 0) {
					cost[nh][nw] = cost[ch][cw] + 1;
					q.add(new Pair(nh, nw));
				}
			}
		}
		if(cost[H-1][W-1]!=0)
			pw.println(H*W-cost[H-1][W-1]-black-1);
		else
			pw.println(-1);
		pw.close();
	}
	
	static class Pair {
		int h; int w;
		Pair(int _h, int _w) {
			h = _h; w = _w;
		}
	}

	static class Scanner
	{
		BufferedReader br;
		StringTokenizer st;
		public Scanner(InputStream s)
		{
			br=new BufferedReader(new InputStreamReader(s));
		}
		public String nextLine() throws IOException
		{
			return br.readLine();
		}
		public String next() throws IOException
		{
			while(st==null || !st.hasMoreTokens())
				st=new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int nextInt() throws IOException
		{
			return Integer.parseInt(next());
			
		}
		public double nextDouble() throws IOException
		{
			return Double.parseDouble(next());
		}
		public boolean ready() throws IOException
		{
			return br.ready();
		}
		public long nextLong() throws IOException
		{
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 21332
class Unionfind:
    
    def __init__(self,n):
        self.uf = [-1]*n

    def find(self,x):
        if self.uf[x] < 0:
            return x
        else:
            self.uf[x] = self.find(self.uf[x])
            return self.uf[x]

    def same(self,x,y):
        return self.find(x) == self.find(y)

    def union(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return 
        if self.uf[x] > self.uf[y]:
            x,y = y,x
        self.uf[x] += self.uf[y]
        self.uf[y] = x

    def size(self,x):
        x = self.find(x)
        return -self.uf[x]

n,k,l = map(int,input().split())


gp = Unionfind(n)
gr = Unionfind(n)

for i in range(k):
    a,b = map(int,input().split())
    gp.union(a-1,b-1)
for i in range(l):
    a,b = map(int,input().split())
    gr.union(a-1,b-1)

l = []
dic = {}
for i in range(n):
    a = gp.find(i) 
    b = gr.find(i)
    s = (a,b)
    l.append(s)
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1
ans = []
for i in range(n):
    ans.append(dic[l[i]])
print(*ans)

Measured memory_bytes: 121180
import java.util.*;
import java.util.Map.Entry;
 
class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
//	 static int mod = 998244353;
   public static void main(String[] args) {
	   
       Scanner sc = new Scanner(System.in);
       int  N = sc.nextInt();
       long sum=0;
       long cnt=0;
       long[] a = new long[N];
       for (int i=0 ; i<N; i++) {
           a[i] = sc.nextLong();
       }

       Arrays.sort(a);
       for(int i=0;i<N-1;i++) {
    	   sum=sum+a[i];
    	   if(sum*2<a[i+1]) {
    		   cnt=i+1;
    	   }
       }
       
       
       System.out.println(N-cnt);
   }
}

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

void fnInput(vector<int>& rvnNum)
{
  for (int& rnElm : rvnNum)
    cin >> rnElm;
}

int fnSameIntTimes(const vector<int>& cnrvnNum)
{
  auto itMaxNum = max_element(begin(cnrvnNum), end(cnrvnNum));

  int  nSum = 0;
  for (int nElm : cnrvnNum)
    nSum += nElm;

  int nSameIntTimes;
  if (*itMaxNum * 3 % 2 == nSum % 2)               // ３数の最大値×３と３数の和のパリティが等しい
    nSameIntTimes = (*itMaxNum * 3 - nSum) / 2;      // ３数の最大値 ← ３数が等しくなる数
  else                                             //  上記以外
    nSameIntTimes = ((*itMaxNum + 1) * 3 - nSum) / 2;// ３数の最大値＋１ ← ３数の等しくなる数

  return nSameIntTimes;
}

int main()
{
  vector<int> vnNum(3);

  fnInput(vnNum);
  cout << fnSameIntTimes(vnNum) << endl;

  return 0;
}

Measured memory_bytes: 256
"use strict";
function Main(input) {
    let I = new Inputer(input);
    let N = I.getInt(), M = I.getInt(), Q = I.getInt();
    let T = new Array(N+1).fill(0).map(() => new Array(N+1).fill(0));
    for (let m = 0; m < M; m++) {
        let l = I.getInt(), r = I.getInt();
        T[l][r] += 1;
    }
    for (let p = 1; p <= N; p++) {
        for (let q = 1; q <= N; q++) {
            T[p][q] += (T[p - 1][q] + T[p][q - 1] - T[p - 1][q - 1]);
        }
    }
    for (let n = 0; n < Q; n++) {
        let p = I.getInt(), q = I.getInt();
        console.log(T[q][q] - T[p - 1][q]);
    }
}
class Inputer {
    constructor (input) {
        this.cnt = 0;
        this.items = input.split(/\n|\s/);
    }
    getInt() {
        return this.items[this.cnt++] - 0;
    }
    getIntArray(N) {
        let a = new Array(N);
        for (let n = 0; n < N; n++) a[n] = getInt();
        return a;
    }
    getStr() {
        return this.items[this.cnt++];
    }
    getStrArray(N) {
        let a = new Array(N);
        for (let n = 0; n < N; n++) a[n] = getStr();
        return a;
    }
}
if (typeof window == "undefined") Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 86112
#include <iostream>
using namespace std;
int main(){
	int n;
	int d[201][4]={};
	int me[101][4]={};
	
	cin>>n;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=3;j++){
			cin>>d[i][j];
			me[d[i][j]][j]++;
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=3;j++){
			if(me[d[i][j]][j]==1)d[i][0]+=d[i][j];
		}
		cout<<d[i][0]<<endl;
	}
	return 0;
}


Measured memory_bytes: 1164
#include <iostream>
#include <string>
#include <vector>
#include <memory>
#include <limits>
#include <algorithm>
#include <stack>
#include <set>
#include <map>
#include <forward_list>
#include <cstdint>

using namespace std;
typedef long long ll;

#define rep(_i,_t) for (int _i=0; _i<(int)_t; _i++)
#define rep1(_i,_t) for (int _i=1; _i<=(int)_t; _i++)

int main()
{
	int H, W, D;
	cin >> H >> W >> D;
	map<int, pair<int, int>> M;
	rep(i, H) {
		rep(j, W) {
			int A;
			cin >> A;
			M[A] = make_pair(i, j);
		}
	}
	vector<ll> cumsum(H * W + 1);
	rep1(i, H*W) {
		if (i > D) {
			auto p1 = M[i - D];
			auto p2 = M[i];
			auto tmp = abs(p1.first - p2.first) + abs(p1.second - p2.second);
			cumsum[i] = cumsum[i - D] + tmp;
		}
	}
	int Q;
	cin >> Q;
	rep(q, Q) {
		int L, R;
		cin >> L >> R;

		ll ans = 0;
		ans += cumsum[R];
		ans -= cumsum[L];
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 7424
#define rep(i,n) for (int i=0;i<n;i++)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector <int> par(1000000);
void unite(int,int);
bool same(int,int);
int root(int);
 
int main(){
    
  int n,m,a,b;
  
  //int n,q,p,a,b;
 
  cin >> n >> m;
  rep(i,n){
    par.at(i)=i;
  }
  
  rep(i,m){
    cin >> a >>b;
    
      unite(a,b);
      
    
  }
  vector <ll> vec(n,0);
  rep(i,n){
    vec.at(root(par.at(i)))++;
  }
  ll c =0;
  rep(i,n){
    c=max(c,vec.at(i));
  }
  cout << c << endl;
}
void unite(int a,int b){
  a=root(a);
  b=root(b);
  
  if(a==b)
    return;
  
  par.at(a)=b;
  
  
}
bool same(int a,int b){
  if(root(a)==root(b))
    return true;
  else
    return false;
}
int root(int x){
  if(par[x]==x)
    return x;
  else{
    return par[x]=root(par[x]);
  }
  
}

Measured memory_bytes: 11792
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
signed main() {
	int n, Ma, Mb; cin >> n >> Ma >> Mb;
	vector<int>a(n), b(n), c(n);
	rep(i, 0, n) {
		cin >> a[i] >> b[i] >> c[i];

	}
	vector<vector<vector<int>>>dp(n + 1, vector<vector<int>>(409, vector<int>(409, INF)));
	dp[0][0][0] = 0;
	rep(i, 0, n) {
		rep(j, 0, 409) {
			rep(k, 0, 409) {
				if (dp[i][j][k] != INF) {
					dp[i + 1][j][k] = min(dp[i][j][k], dp[i + 1][j][k]);

					dp[i + 1][j+a[i]][k+b[i]] = min(dp[i + 1][j+a[i]][k+b[i]], dp[i][j][k] + c[i]);
				}
			}
		}
	}
	int ans = INF;
	rep(i, 1, 409) {
		rep(j, 1, 409) {
			if (i*Mb == j*Ma)ans = min(ans, dp[n][i][j]);
		}
	}
	cout << ((ans == INF) ? -1 : ans) << endl;
	return 0;
}

Measured memory_bytes: 28288
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
using ll = long long;
int main(){
  int n, p;
  cin >> n >> p;
  string s;
  cin >> s;
  if(10%p == 0){ //pが2か5の時
    ll ans = 0;
    for(int r = 0; r < n; r++){
      if((s[r]-'0') % p == 0){
        ans += r + 1;
      }
    }
    cout << ans << '\n';
    return 0;
  }
  int ten = 1;
  vector<int> d(n + 1, 0);
  for(int i = n - 1; i >= 0; i--){
    int a = (s[i] - '0') * ten % p;
    d[i] = (d[i + 1] + a) % p;
    ten *= 10;
    ten %= p;
  }
  vector<int> count(p);
  ll ans = 0;
  for(int i = n; i >= 0; i--){
    ans += count[d[i]];
    count[d[i]]++;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 1412
import java.util.*;

class Main{
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    int min_n = -1, min_i = -1, sum = 0;
    int a[] = new int[5];
    for (int i = 0; i < 5; i++) {
      a[i] = sc.nextInt();
      if (i == 0 || a[i] % 10 < min_n && a[i] % 10 != 0) {
        min_n = a[i] % 10;
        min_i = i;
      }
    }
    for (int i = 0; i < 5; i++) {
      if (i == min_i) {
        sum += a[i];
      }
      else if (a[i] % 10 != 0){
        sum += a[i] + (10 - (a[i]%10));
      }
      else {
        sum += a[i];
      }
    }
    System.out.println(sum);
  }
}


Measured memory_bytes: 22736
#include <cstdio>
#include <cstring>
#include <algorithm>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

using ll = long long;

ll N, W;
ll w[110], v[110];
ll dp[110][100010];

ll rec( ll i, ll j )
{
  ll &ret = dp[i][j];

  if( ~ret )
    return ret;

  if( i == N )
  {
    ret = 0;

    return ret;
  }

  ret = std::max( ret, rec( i+1, j ) );

  if( j-w[i] >= 0 )
    ret = std::max( ret, rec( i+1, j-w[i] )+v[i] );

  return ret;
}

int main()
{
  scanf( "%lld%lld", &N, &W );
  rep( i, N )
    scanf( "%lld%lld", w+i, v+i );

  memset( dp, -1, sizeof(dp) );

  printf( "%lld\n", rec( 0, W ) );

  return 0;
}

Measured memory_bytes: 86144
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    vector<int>path[n+5];
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        path[x].push_back(y);
        path[y].push_back(x);
    }
    queue<pair<int,int>>q;
    q.push({1,0});
    int visited[n+5];
    int ans[n+5];
    memset(ans,-1,sizeof ans);
    memset(visited,0,sizeof visited);
    visited[1]=1;
    ans[1]=0;
    while(!q.empty())
    {
        pair<int,int>p=q.front();
        q.pop();
        for(auto itr : path[p.first])
        {
            if(visited[itr])
            continue;
            else
            {
                visited[itr]=1;
                ans[itr]=p.second+1;
                q.push({itr,p.second+1});
            }
        }
    }
    /*for(int i=1;i<=n;i++)
    cout<<ans[i]<<" ";
    cout<<'\n';*/
    int i=0;
    for(i=1;i<=n;i++)
    {
        if(ans[i]==-1)
        break;
    }
    if(i!=n+1)
    cout<<"No"<<'\n';
    else
    {
        cout<<"Yes"<<'\n';
        for(int i=2;i<=n;i++)
        {
            int mn=1000000000;
            int j=1;
            for(auto itr : path[i])
            {
                //cout<<itr<<" ";
                if(ans[itr]<mn)
                {
                    mn=ans[itr];
                    j=itr;
                }
            }
            cout<<j<<'\n';
        }
    }
    return 0;
}

Measured memory_bytes: 11024
import sys
from itertools import product
import copy

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    H, W = map(int, input().split())
    A = [list(input()) for _ in range(H)]

    grid_init = [["." for _ in range(W)] for _ in range(H)]
    grid_init[0][0] = "#"
    for pattern in product(["L", "D"], repeat=H + W - 2):
        grid = copy.deepcopy(grid_init)
        if pattern.count("L") == W - 1 or pattern.count("D") == H - 1:
            h, w = 0, 0
            for p in pattern:
                if p == "L":
                    w += 1
                else:
                    h += 1
                grid[h][w] = "#"

            flg = True
            for h in range(H):
                for w in range(W):
                    if A[h][w] != grid[h][w]:
                        flg = False
                        break

            if flg:
                print("Possible")
                break
    else:
        print("Impossible")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3436
//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj
#include<bits/stdc++.h>
using namespace std;
//int input........
template <typename T> inline void readline(T &n) {n = 0; int f = 1; register int ch = getchar();
 for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;for (; isdigit(ch); 
ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';n = n * f;}
template <typename T, typename TT> inline void readline(T &n, TT &m) { readline(n); readline(m); }
template <typename T, typename TT, typename TTT> inline void readline(T &n, TT &m, TTT &l) { readline(n, m); readline(l);}
// long long input........
template <typename T> inline void readlinel(T &n) {n = 0; long long f = 1; register long long ch = getchar();
 for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;for (; isdigit(ch); 
ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';n = n * f;}
template <typename T, typename TT> inline void readlinel(T &n, TT &m) { readlinel(n); readlinel(m); }
template <typename T, typename TT, typename TTT> inline void readlinel(T &n, TT &m, TTT &l) { readlinel(n, m); readlinel(l);}
//debug..........
#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s, char c) {vector<string>v; stringstream ss(s); string x;
while (getline(ss, x, c))v.emplace_back(x); return move(v);} void err(vector<string>::iterator it) {}
template<typename T, typename... Args>void err(vector<string>::iterator it, T a, Args...args) {
cout << it->substr((*it)[0] == ' ', it->length()) << " = " << a << " "; err(++it, args...);}
//............ignore it..................//
int dx[8]= {1,0,-1,0,-1,-1,1,1};int dy[8]= {0,1,0,-1,-1,1,-1,1}; int tc = 1;
#define pb  push_back
#define mp make_pair
#define ll  long long int
#define endl  '\n';
#define happy cin.tie(0);
#define coding ios::sync_with_stdio(false);
#define Test printf("Case %d: ",tc++);
void print(int n){printf("%d ", n);}
void print(int n,int m){printf("%d ",n);printf("%d ",m);}
void print(int n,int m,int k){printf("%d ",n);printf("%d ",m);printf("%d ",k);}
void print(ll n){printf("%I64d ", n);}
void print(ll n,ll m){printf("%I64d ",n);printf("%I64d ",m);}
void print(ll n,ll m,ll k){printf("%I64d ",n);printf("%I64d ",m);printf("%I64d ",k);}
#define   pr 	pair<int, int> 
#define   vpr 	vector<pr> 
#define   vi   	std::vector<int>
#define   vll  	std::vector<ll>
#define   map   std::map<string, int>
#define   all(n) n.begin(),n.end()
const int mod           = 1e9 + 7;
const int Inf           = (int)2e9 + 5;
const ll  Lnf           = (ll)2e18 + 5;
const int N             =2e5 + 5;
const int N1            = 1e5 + 5;

int dp[N];

int solve() 
{
	//happy coding

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

	dp[1] = 0;dp[2] = abs(a[2]-a[1]);

	for(int i=3;i<=n;i++){
		dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
	}
	cout<<dp[n]<<endl;
	
	return 0;
	//error();
}
int main(){
	int test = 1;
	//readline(test);//(void)getchar();
	while (test--)solve();return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(){
	int N;
	char s[101];
	cin >> N;
	
	cin >> s;

	int leftcount = 0;
	int needleft = 0;

	int leftnum=0, rightnum=0;
	for (int i=0; i<N; i++) {
		if (s[i] == '(') {
			leftnum++;
			if (leftcount < 0) {
				needleft += -leftcount;
				leftcount = 0;
			}
			leftcount++;
		} else {
			rightnum++;
			leftcount--;
		}
	}
	if (leftcount < 0) {
		needleft += -leftcount;
		leftcount = 0;
	}

	int needright = leftnum + needleft - rightnum;
	if (needright < 0) needright = 0;

	for (int i=0; i<needleft; i++) {
		cout << '(';
	}
	for (int i=0; i<N; i++) {
		cout << s[i];
	}
	for (int i=0; i<needright; i++) {
		cout << ')';
	}



	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long T;
 
struct point { 
    T x,y;
    int i; 
    point operator - (const point &rhs) {
        return {x-rhs.x, y-rhs.y};
    }
    T dot(const point &rhs) {
        return x*rhs.x + y*rhs.y;
    }
    T cross(const point &rhs) {
        return x*rhs.y - y*rhs.x;
    }
    T len2() {
        return x*x + y*y;
    }
};
 
int compare(T x, T y) {
    if(y-x > 0) return -1;
    if(x-y > 0) return 1;   
    return 0;
}
 
T cross(point p, point q, point r) { return (r-q).cross(p-q); }
 
int turn(point p, point q, point r) { return compare(cross(p,q,r), 0); }
 
int cw(point p, point q, point r) { return turn(p,q,r) < 0; }
 
 /*
double angle(point p, point q, point r) 
{
    point v = r - q;
    point u = p - q;
    return acos(v.dot(u) / sqrt(v.len2() * u.len2())); 
}
*/
// modulo^2 de un punto (distance to origin)
T norm2(point p) { return p.x * p.x + p.y * p.y; }


double angle(point a, point o, point b) // angle AOB (radians)
{
   point u = {a.x - o.x, a.y - o.y}; // u: vector oa
   point v = {b.x - o.x, b.y - o.y}; // v: vector ob
   return acos(u.dot(v) / sqrt(1.0 * norm2(u) * norm2(v))); // dot product
}

 
bool cmp(const point &p, const point &q)
{
    return p.x < q.x || (p.x == q.x && p.y < q.y);
}
 
vector<point> convex_hull(vector<point> &p)
{
    int n = (int)p.size(), k = 0;
    vector<point> h(2 * n);
    sort(p.begin(), p.end(), cmp);
    for(int i = 0; i < n; i++) 
    {
        while(k >= 2 && cw(h[k-2], h[k-1], p[i])) k--;
        h[k++] = p[i];
    }
    for(int i = n - 2, t = k + 1; i >= 0; i--) 
    {
        while(k >= t && cw(h[k-2], h[k-1], p[i])) k--;
        h[k++] = p[i];
    }
    h.resize(k); h.pop_back(); 
    return h;
}
 
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(10);
    int n,m;
    vector<point> p,h;
    double ans[105];
    while(cin >> n)
    {
        p = vector<point>(n);
        for(int i = 0; i < n; i++)
        {
            cin >> p[i].x >> p[i].y;
            p[i].i = i;
        }
        h = convex_hull(p);
        for(int i = 0; i < n; i++)
            ans[i] = 0;
        m = h.size();
        for(int i = 0; i < m; i++)
            ans[h[i].i] = (M_PI - angle(h[(i-1+m)%m], h[i], h[(i+1)%m])) / (2*M_PI);
        for(int i = 0; i < n; i++)
            cout << ans[i] << '\n';
    }
    return 0;
} 

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

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

    long long n = s.size(), ans = 0;
    for(int bits = 0; bits < (1 << n - 1); ++bits){
        int i = n;
        for(int j = 0; j < n - 1; ++j){
            if(bits & (1 << j)){
                int index = n - 1 - j;
                ans += std::atoll(s.substr(index, i - index).c_str());
                i = index;
            }
        } 
        
        ans += std::atoll(s.substr(0, i).c_str());
    }

    std::cout << ans << std::endl;

    return 0;
}

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

namespace AtcoderSubmit
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ulong.Parse(Console.ReadLine());
            var aList = new int[N];
            var bList = new int[N];
            for(int i = 0; (ulong)i < N; i++) {
                var line = Console.ReadLine().Split(' ');
                aList[i] = int.Parse(line[0]);
                bList[i] = int.Parse(line[1]);
            }
            Array.Sort(aList);
            Array.Sort(bList);

            int ans = 0;
            if(N % 2 == 0) {
                int aMed2 = aList[N / 2 - 1] + aList[N / 2];
                int bMed2 = bList[N / 2 - 1] + bList[N / 2];
                ans = Math.Abs(aMed2 - bMed2) + 1;
            }
            else {
                int aMed = aList[N / 2];
                int bMed = bList[N / 2];
                ans = Math.Abs(aMed - bMed) + 1;
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 42120
import sys
from sys import exit
from math import gcd, factorial, ceil, floor, sqrt
from bisect import bisect_left, bisect_right
from copy import deepcopy
from heapq import heapify, heappop, heappush
from itertools import permutations, combinations, product, accumulate
from collections import defaultdict, deque, Counter
sys.setrecursionlimit(10**7)

ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(map(int, input().split()))

D, T, S = mi()
if D <= T*S:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9580
n, k = gets.chomp.split(' ').map(&:to_i)
nums = gets.chomp.split(' ').map(&:to_i)

h = Hash.new(0)
nums.each do |num|
  h[num] += 1
end

info = h.sort_by { |_num, count| count }
decrease_count = info.size - k
answer = 0
decrease_count.times do |i|
  answer += info[i].last
end

puts answer

Measured memory_bytes: 42240
s=str(input())
t=str(input())
temp=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
s=list(s)
t=list(t)
temps=[0]*len(temp)
tempt=[0]*len(temp)
for i in range(0,len(temp)):
  temps[i]=s.count(temp[i])
  tempt[i]=t.count(temp[i])
temps.sort()
tempt.sort()
if temps==tempt:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 6704
#include<bits/stdc++.h>
#define rep(i, n) for (long long i = 0; i < (int)(n); i++)
#define sum(a) accumulate(a.begin(),a.end(),0LL)
#define all(a) a.begin(), a.end()
#define put(i) cout<<fixed<<i<<endl
using namespace std;
using ll = long long;

int main(){
    ll x; cin >> x;
    put((x xor 1));
}

Measured memory_bytes: 3628
n = int(input())
a = []
for i in range(n):
    a.append([i, int(input())])
a.sort(key=lambda x: x[1])
ans = [0 for _ in range(n)]
for i in range(n):
    index = a[i][0]
    ans[index] = a[-2][1] if i == (n-1) else a[-1][1]
for a in ans:
    print(a)


Measured memory_bytes: 39428