akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 0
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
#define MAX_W 15
#define MAX_H MAX_W

#define FAKE_ANS

ll W, H;
vector<string> S;

// 列の入れ替えのみで点対象にできるなら true
bool CheckCol(const vector<string>& s) {
    bool isUsedMapped[MAX_W] = {};
    bool isUsedS[MAX_W] = {};
    bool isFind = false;
    ll mapped_ind_head = 0;
    ll mapped_ind_tail = W-1;
    ll dbg_cnt = 0;
    REP(i, W) {
        if(isUsedS[i]) { continue; }
        isFind = false;
        isUsedS[i] = true;
        // i 列を上下反転したような列 j を探す
        REP(j, W) {
            if(isUsedS[j]) { continue; }
            bool isRev = true;
            REP(k, H) { if(s[k][i] != s[H-1-k][j]) { isRev = false; break; } }
            // 上下反転があった
            if(isRev) {
                DBG("%lld %lld is pair.\n", i, j);
                isUsedS[j] = true;
                isUsedMapped[mapped_ind_head] = true;
                isUsedMapped[mapped_ind_tail] = true;
                mapped_ind_head++;
                mapped_ind_tail--;
                dbg_cnt += 2;
                isFind = true;
                break;
            }
        }
        if(!isFind) {
            DBG("%lld is not pair.\n", i);
            // 上下反転がなかった
            if(W % 2 == 0) { return false; }
            else {
                // 奇数なら、列が上下対象なら真ん中に置ける
                bool isSym = true;
                REP(j, H / 2) { if(s[j][i] != s[H-1-j][i]) { isSym = false; break; } }
                if(isSym && !isUsedMapped[W / 2]) {
                    DBG("  But can mapped %lld\n", W / 2);
                    isUsedMapped[W / 2] = true;
                    dbg_cnt++;
                } else {
                    return false;
                }
            }
        }
    }
    assert(dbg_cnt == W);
    return true;
}

signed main()
{
    cin >> H >> W;
    REP(i, H) {
        string tmp_s;
        cin >> tmp_s;
        S.push_back(tmp_s);
    }

#ifdef FAKE_ANS
    // 簡易チェック
    if(CheckCol(S)) {
        printf("YES\n");
        return 0;
    }
    // 偽解法
    // 点対称において意味のある入れ替え方法は 11!! = 10395 だが
    // その入れ替えパターン列挙が面倒なのでランダムに行をシャッフル
    // 10^6 くらいやったら 10395 パターンが全部出るのではないかという期待
    random_device r;
    mt19937 mt(r());
    REP(i, 1000000) {
        vector<string> sh;
        REP(j, H) { sh.push_back(S[j]); }
        shuffle(sh.begin(), sh.end(), mt);
        if(CheckCol(sh)) {
            printf("YES\n");
            return 0;
        }
    }
    printf("NO\n");
    return 0;
#else
    // 行のペアを作成
#endif
    return 0;
}


Measured memory_bytes: 384
package main

import "fmt"
import "math"

func main(){
	var A, B, H, M float64
	var ans float64;
	var kakudo float64;

	fmt.Scan(&A, &B, &H, &M);

	if H*30+M*0.5 - M*6 < 180 {
		kakudo = H*30+M*0.5 - M*6;
	}else {
		kakudo = 360 -(H*30+M*0.5 - M*6);
	}
	//fmt.Println(kakudo);
	kakudo = kakudo / 180 * math.Pi;
	kakudo = math.Cos(kakudo);
//	fmt.Println(kakudo);
	ans = (A*A) + (B*B) - (2*A*B * kakudo);
	fmt.Println(math.Sqrt(ans));
}

Measured memory_bytes: 1824
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
  int n, k;
  cin>>n>>k;
  int a[n];
  for(int i=0; i<n; ++i)
    cin>>a[i];
  int dp[n+1]={};
  for(int i=1; i<n; ++i)
  {
    dp[i]=LLONG_MAX;
    for(int j=i-1; j>=max((int)0, i-k); --j)
    	dp[i]=min(dp[j]+abs(a[j]-a[i]), dp[i]);
  }
  cout<<dp[n-1];
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define w(t) int t;cin>>t; while(t--)
using namespace std;

int main(){
    ll n, k;
    cin>>n>>k;
    ll arr[n];
    for(ll i=0; i<n; i++) cin>>arr[i];
    ll dp[n];
    memset(dp, 0, sizeof(dp));
    dp[0] = 0;
    for(ll i=1 ;i<n; i++){
        ll j;
        if(i-k < 0){
            j=0;
        }
        else j=i-k;
        ll mn = INT_MAX;
        while(j<i){
            mn = min(mn, abs(arr[j]-arr[i])+dp[j]);
            j++;
        }
        dp[i] = mn;
    }
    cout<<dp[n-1];
}

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

int main() {
    int A , B ; //−100 ≤ A,B ≤ 100
    int X , Y , Z ;
    cin >> A >> B ;
    X = A + B;
    Y = A - B;
    Z = A * B;
    if ( X >= Y && X >= Z) cout << X << endl;
    else if (Y >= X && Y >= Z) cout << Y << endl;
         else cout << Z << endl;
	return 0;
}

Measured memory_bytes: 3608
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
import std.concurrency;
void times(alias fun)(int n) {
    foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(int n) {
    T[] res = new T[n];
    foreach(ref e; res) e = fun();
    return res;
}

long MOD = 10L^^9+7;
void main() {
    int N = readln.chomp.to!int;
    getPrimes(N).map!(p =>
        N.iota.map!"a+1".map!((n) {
            long res = 0;
            while(n%p == 0) {
                n/=p;
                res++;
            }
            return res;
        }).fold!((a, b) => (a+b)%MOD)(1L)
    ).fold!((a, b) => a*b%MOD)(1L).writeln;
}

int[] getPrimes(int limit) {
    bool[] isPrimes = new bool[limit+1];
    isPrimes[2..$] = true;
    for (int i=2; i*i<=isPrimes.length; i++) {
        if (isPrimes[i]) {
            for (int j=i*i; j<isPrimes.length; j+=i) {
                isPrimes[j] = false;
            }
        }
    }
    int[] primes = [];
    foreach (int i, flg; isPrimes) {
        if (flg) primes ~= i;
    }
    return primes;
}

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

// fold was added in D 2.071.0
static if (__VERSION__ < 2071) {
    template fold(fun...) if (fun.length >= 1) {
        auto fold(R, S...)(R r, S seed) {
            static if (S.length < 2) {
                return reduce!fun(seed, r);
            } else {
                return reduce!fun(tuple(seed), r);
            }
        }
    }
}

// minElement/maxElement was added in D 2.072.0
static if (__VERSION__ < 2072) {
    auto minElement(alias map, Range)(Range r)
    if (isInputRange!Range && !isInfinite!Range)
    {
        alias mapFun = unaryFun!map;
        auto element = r.front;
        auto minimum = mapFun(element);
        r.popFront;
        foreach(a; r) {
            auto b = mapFun(a);
            if (b < minimum) {
                element = a;
                minimum = b;
            }
        }
        return element;
    }
    auto maxElement(alias map, Range)(Range r)
    if (isInputRange!Range && !isInfinite!Range)
    {
        alias mapFun = unaryFun!map;
        auto element = r.front;
        auto maximum = mapFun(element);
        r.popFront;
        foreach(a; r) {
            auto b = mapFun(a);
            if (b > maximum) {
                element = a;
                maximum = b;
            }
        }
        return element;
    }
}


Measured memory_bytes: 256
a = []
a.append(int(input()))
ans = 0
def f_even(x):
        return x//2

def f_odd(x):
        return 3 * x + 1

for i in range(1000000):
        if a[i] % 2 == 0:
                a.append(f_even(a[i]))
        if a[i] % 2 == 1:
                a.append(f_odd(a[i]))
        for t in range(i):
                if a[i+1] == a[t]:
                        ans = i + 2
                        break
        else:
                continue
        break
print(ans)

Measured memory_bytes: 3064
using System;
using System.Linq;

public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var min = a.Min();
        var max = a.Max();
        Console.WriteLine(2 * n - 1);
        if (min + max < 0)
        {
            var minInd = Array.IndexOf(a, min) + 1;
            for (int i = 1; i <= n; i++) Console.WriteLine($"{minInd} {i}");
            for (int i = n; i >= 2; i--) Console.WriteLine($"{i} {i - 1}");
        }
        else
        {
            var maxInd = Array.IndexOf(a, max) + 1;
            for (int i = 1; i <= n; i++) Console.WriteLine($"{maxInd} {i}");
            for (int i = 1; i <= n - 1; i++) Console.WriteLine($"{i} {i + 1}");
        }
    }
}


Measured memory_bytes: 13396
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner stdIn=new Scanner(System.in);
      int A=stdIn.nextInt();
      int B=stdIn.nextInt();
      if(A<9&&B<9){
        System.out.println("Yay!");
      }else{
        System.out.println(":(");
      }
  }
}

Measured memory_bytes: 21844
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int q = Integer.parseInt(br.readLine());
      String[] s = new String[q+q];
      Arrays.fill(s, "");
      List<String> list  = Arrays.asList(s);
      int head = q;
      int tail = q;

      String[] query;
      int op;
      int terms;
      for ( int i=0; i<q; i++ ){
        query = br.readLine().split(" ");
        op  = Integer.parseInt(query[0]);

        switch( op ) {
          case 0 :
            terms = Integer.parseInt(query[1]);
            if ( terms == 0 ) {
              list.set(head--,query[2]); }
            else {
              list.set(++tail,query[2]); }
            break;
          case 1 :
            System.out.println( list.get(head + Integer.parseInt(query[1]) + 1) );
            break;
          case 2 :
            terms = Integer.parseInt(query[1]);
            if ( terms == 0 ) {
              list.set(head++,"");  }
            else {
              list.set(tail--,"");  }
            break;
          default:
        }
      }
    }
  }
}


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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

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

   int cnt=0;
   rep(i, s.size()) if(s[i]!=t[i]) cnt++;

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


Measured memory_bytes: 3856
# -*- coding: utf-8 -*-
r, g, b, n = map(int, input().split())

nr_max = n // r
ng_max = n // g

count = 0
for i in range(nr_max + 1):
    tmp1 = r * i
    if tmp1 == n:
        count += 1
        break
    res = n - tmp1
    for j in range(res // g + 1):
        tmp2 = g * j + tmp1
        if tmp2 == n:
            count += 1
        if tmp2 >= n:
            break
        if (n - tmp2) % b == 0:
            count += 1

print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s;
	cin>>s;
	int ans=0;
	for(int i=0; i<s.size(); i++)
	 ans+=(s[i]-'0');
	if(ans%9==0)
	 cout<<"Yes";
	else
	 cout<<"No";
	return 0;
	
}

Measured memory_bytes: 3740
//g++ -std=gnu++14 a.cpp
#include <bits/stdc++.h>
/*
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
*/


using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> h(M);
  rep(i,M) cin >> h.at(i);
  int sum = 0;
  rep(i,M){
    sum += h[i];
  }
  if(sum <= N){
    cout << N-sum << endl;
  }else{
    cout << -1 << endl;
  }
}


Measured memory_bytes: 3672
function Main(input) {
	inputs = input.split("\n");
	input = inputs[1].split(" ").map(Number);
	ans = true;
	culc = 0;
	temp = 0;
	
	for(var i = 0; i < input.length - 1; i++){
		if(input[i + 1] < input[i]){
			if(culc == 0){
				temp = input[i];
				number = i;
				culc++;
			}else{
				input[number] = input[i + 1];
				input[i + 1] = temp;
			}
		}
	}
	
	for(var i = 0; i < input.length - 1; i++){
		if(!(input[i] < input[i + 1])){
			ans = false;
		}
	}
	
	if(ans){
		console.log("YES");
	}else{
		console.log("NO");
	}

}Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main()
{
    string S;
    cin >> S;
    set<char> s;
    for (int i = 0; i < 3; i++)
        s.insert(S[i]);
    if (s.size() == 3)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int ac, wa, tle, re;

int main()
{
	cout << fixed << setprecision(10);

	int n;
	cin >> n;

	
	REP(i, n)
	{
		string s;
		cin >> s;
		if (s == "AC")ac++;
		if (s == "WA")wa++;
		if (s == "TLE")tle++;
		if (s == "RE")re++;
	}
	cout << "AC x " << ac << endl;
	cout << "WA x " << wa << endl;
	cout << "TLE x " << tle << endl;
	cout << "RE x " << re<<endl;
	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll ;
typedef double db;
const double pi = acos(-1) ;
#define pb         push_back
#define forab(i,a,b)       for(int i=(a);i<=(b);i++)
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)
#define pcase(z,x)     printf("Case %ld: %lld\n",z,x)
#define nw				"\n"


int main(void)
{
	CIN;
	ll tc,l,k,sum=0,x=0,y,z=0,m=1,n=0,ans=0;
	cin>>n;
	x=1;
	while(x<=n)
		x*=2;
	cout<<x/2;

}


Measured memory_bytes: 3632
#include <stdio.h>

int main(){
    int a[1000000];
    int i = 1, result;
    scanf("%d", &a[1]);
    while(i > 0){
        i++;
        if(a[i-1] % 2 == 0) a[i] = a[i-1] / 2;
        else a[i] = a[i-1] * 3 + 1;
        for(int j = 1; j < i; j++){
            if(a[i] == a[j]){
                result = i;
                i = -1;
            }
        }
    }
    printf("%d\n", result);
	return 0;
}


Measured memory_bytes: 128
program name
    implicit none
    integer(4)::kp(4)
    integer(4):: bit(3), ansbit(3)
    integer(4):: i,j, ans
    character(7):: cans
    character(4):: inpt


    read*, inpt

    do i=1,4
        kp(i) = ichar(inpt(i:i)) - ichar('0')
    end do

    do i=0,7
        do j=1,3
            bit(j) = and(rshift(i,j-1),1)
        end do
        ans=kp(1)
        do j=1,3
            if (bit(j) == 1) then
                ans=ans+kp(j+1)
            else
                ans=ans-kp(j+1)
            end if
        end do
        if (ans == 7) ansbit = bit
    end do

    do i=1,4
        cans(2*i-1:2*i-1) = char(kp(i)+ichar('0'))
    end do

    do i=1,3
        if (ansbit(i) == 1)then
            cans(2*i:2*i) = '+'
        else
            cans(2*i:2*i) = '-'
        end if
    end do

    print*, cans(:),'=7'
end program name

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

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n,x,t;
	cin >> n >> x >> t;
	int a;
	if(n%x==0) a=n/x;
	else a=(n/x)+1;
	cout << t*a << endl;
	
	return 0;
}

Measured memory_bytes: 3608
//----------BHAVIK DIWANI(PICT_COMP)---------------
	#include<bits/stdc++.h>
	#include<stdlib.h>
	#include<stdio.h>
	#define test ll t; cin>>t; while(t--)
	#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
	#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define mod 1000000007
	#define ll long long
	#define int long long
	#define ull unsigned long long
	#define MAX 1000005
	#define pb push_back
	#define mkp make_pair
	#define vi vector<int>
	#define pii pair<int,int>
	#define endl '\n'
	#define vs vector<string>
	#define mii map<int,int>
	#define msi map<string,int>
	#define vpii vector< pair<int, int > >
	#define vpsi vector< pair< string ,int > >
	#define forci(p,q) for(int i=p;i<q;i++)
	ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
	ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
	ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
	ll modmul(ll x, ll y){return (x*y)%mod;}
	ll modadd(ll x, ll y){return (x+y)%mod;}
	ll modsub(ll x, ll y){return (x-y+mod)%mod;}
	ll fact[1000007]={0};
	void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
	ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
	ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
	inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
	inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
	inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
	/*bool prime[MAX];
	ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
	}*/
	using namespace std;
	signed main()
	{
		fastio;
		int n,k;
		cin>>n>>k;
		int h[n+1];
		int m[n+1]={0};
		int ans=0;
		int x,y;
		for(int i=1;i<=n;i++)
			cin>>h[i];
			
		for(int i=0;i<k;i++)
		{
			cin>>x>>y;
			m[x]=max(m[x],h[y]);
			m[y]=max(m[y],h[x]);
		}
		for(int i=1;i<=n;i++)
		{
			if(h[i]>m[i])
				ans+=1;
		}
		cout<<ans<<endl;
	}

Measured memory_bytes: 5196
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>
#include<numeric>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,x,y) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0LL)
#define scan(x) scanf("%lld",&x)
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
typedef double D;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;
const D pi = acos(-1);
const D eps = 1e-10;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok, flag;
ll dx[5] = { 1,-1,0,0,0 }, dy[5] = { 0,0,1,-1,0 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111


int main(void) {
  cin >> n >> m;
  vll a(n);
  rep(i, n) scan(a[i]);
  rep(i, n) a[i] %= m;
  MAP mp;
  ll sum = 0;
  mp[0]++;
  rep(i, n) {
	(sum += a[i]) %= m;
	ans += mp[sum];
	mp[sum]++;
  }
  cout << ans << endl;

  return 0;
}

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

using namespace std;

bool impossible(char ch1, set<char> has, map<char, set<char> > mp) {
  if (has.find(ch1) != has.end()) return true;
  has.insert(ch1);

  bool res = false;
  for (auto ch2 : mp[ch1]) {
    res |= impossible(ch2, has, mp);
  }
  return res;
}

void solve(void) {
  int h, w;
  cin >> h >> w;

  vector<string> s(h);
  for (int i = 0; i < h; i++) {
    cin >> s[i];
  }

  set<char> st;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (s[i][j] != '.') {
        st.insert(s[i][j]);
      }
    }
  }

  bool ng = false;
  map<char, set<char> > mp;
  for (auto ch : st) {
    int u = 51, d = -1, l = 51, r = -1;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (s[i][j] == ch) {
          u = min(u, i);
          d = max(d, i);
          l = min(l, j);
          r = max(r, j);
        }
      }
    }

    for (int i = u; i <= d; i++) {
      for (int j = l; j <= r; j++) {
        if (s[i][j] == '.') {
          ng = true;
        } else if (s[i][j] != ch) {
          mp[ch].insert(s[i][j]);
        }
      }
    }
  }

  for (auto ch1 : st) {
    set<char> has;
    has.insert(ch1);
    for (auto ch2 : mp[ch1]) {
      ng |= impossible(ch2, has, mp);
    }
  }

  cout << (ng ? "SUSPICIOUS" : "SAFE") << endl;
}

int main(void) {
  int n;
  cin >> n;

  for (int i = 0; i < n; i++) {
    solve();
  }

  return 0;
}


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

#define ll long long int
#define vi vector<int>
#define ii pair< int , int >
#define vii vector<ii>
#define FOR(i, n) for(ll i = 0; i < (ll)n; i++)
int MAX(int a, int b){return (a > b) ? a:b;}
int MIN(int a, int b){return (a < b) ? a:b;}
int ABS(int x){return (x > 0) ? x:-x;}
int left(int x){return (x<<1);}
int right(int x){return (x<<1)+1;}
int lsone(int x){return (x&(-x));}

const int maxn = 3e3 + 1;

int n;
double p[maxn];
double ans[maxn][maxn];
bool found[maxn][maxn];

double dp(int pos, int head){
	if(pos == n){
		if(head > n-head) return 1.00;
		return 0.00;
	}
	if(found[pos][head]) return ans[pos][head];
	found[pos][head] = true;
	ans[pos][head] = dp(pos+1, head+1)*p[pos];
	ans[pos][head] += dp(pos+1, head)*(1.00-p[pos]);
	return ans[pos][head];
}

int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%lf", &p[i]);
	}
	printf("%.15lf\n", dp(0, 0));
}

Measured memory_bytes: 79488
#include <algorithm>
#include <iostream>
#include <list>
#include <map> //連想配列
#include <queue>
#include <set> //
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector> //動的配列

using namespace std;

int main() {
  char *o = (char *)malloc(51);
  char *e = (char *)malloc(51);
  cin >> o >> e;
  int n = 0;
  while (*(o + n) != '\0' || *(e + n) != '\0') {
    if (*(o + n) != '\0' && *(e + n) == '\0') {
      cout << *(o + n);
    } else {
      cout << *(o + n) << *(e + n);
    }
    n = n + 1;
  }

  cout << endl;
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = (a); i < int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())

using namespace std;
using i32 = int;
using i64 = long long;
using f64 = double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf64 = vector<f64>;
using vstr = vector<string>;

template<typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; }
template<typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; }

template<class T> T gcd(T a, T b) {
  if (a % b == 0) return b;
  else return gcd(b, a % b);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  int n, k;
  cin >> n >> k;
  vi32 a(n);
  rep(i, n) cin >> a[i];
  sort(all(a)); reverse(all(a));
  int mn = a[0];
  reps(i, n - 1) mn = gcd(mn, a[i]);
  rep(i, n) {
    if (a[i] < k) break;
    if ((a[i] - k) % mn == 0) {
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#define ll long long int 
using namespace std;
vector<ll> dp(100005,-1);


ll depth(vector<ll> adj[],ll i)
{  
   if(adj[i].size()==0)
       return 0;
    ll ans=0;   
    
    if(dp[i]!=-1)
      return dp[i];
    
    for(auto c : adj[i])
     {
         ans=max(ans,depth(adj,c)+1);
     }
    return dp[i]=ans;
}


int main()
{
    ll n,m,x,y;
    cin>>n>>m;
    
    vector<ll> adj[n+1];
    
    for(ll i=0;i<m;i++)
    {
        cin>>x>>y;
        adj[x].push_back(y);
    }
    ll maxd=0;
    for(ll i=1;i<=n;i++)
    maxd=max(maxd,depth(adj ,i));
    
    cout<<maxd;
    return 0;
}


Measured memory_bytes: 8576
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int n,res[10010];
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int x=1;x<=100;x++){
		for(int y=1;y<=100;y++){
			for(int z=1;z<=100;z++){
				if(x*x+x*y+x*z+y*y+y*z+z*z<=n){
					res[x*x+x*y+x*z+y*y+y*z+z*z]++;
				}
			}
		}
	}
	for(int i=1;i<=n;i++) cout<<res[i]<<endl;
	return 0;
}


Measured memory_bytes: 3692
def collatz(n):
    c = 0
    while n > 1:
        if n % 2 == 0:
            n  = n / 2
            c += 1
        else:
            n = n * 3 + 1 
            c += 1
    return c
    
while 1:
    n = int(input())
    if n == 0:
        break
    else:
        print(collatz(n))



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

int main() {
  string S[3] = {"Sunny", "Cloudy", "Rainy"};
  string s;
  cin >> s;

  if(s == S[0]) cout << S[1] << endl;
  else if(s == S[1]) cout << S[2] << endl;
  else cout << S[0] << endl;


}


Measured memory_bytes: 256
import sys
import math
import collections
import bisect
import itertools

# import numpy as np

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

ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: map(int, sys.stdin.readline().rstrip().split())
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))


# ===CODE===
# 最小公倍数
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)


def main():
    n = ni()
    t, a = 1, 1

    for _ in range(n):
        ti, ai = ns()

        # if ti == ai:
        #     t = max(t, a)
        #     a = max(t, a)
        #     continue

        x = t // ti
        x += 1 if t % ti else 0
        y = a//ai
        y += 1 if a % ai else 0

        nxt = max(x, y)

        t, a = ti * nxt, ai * nxt

    print(t + a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9472
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>
#include<cassert>

using namespace std;

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

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = INF+7;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define rep(i,n) FOR(i,0,n)

struct edge{int to,cost;};

void dump_line(ll *b,int n){
	for(int i=0;i<n;i++){
		cout << b[i] << " ";
	}
	cout << "\n";
}

ll mypow(ll x,ll n){
	if(n==0) return 1;
	ll res=mypow(x*x,n/2);
	if(n&1) res=res*x;
	return res;
}

ll mod_pow(ll x,ll n,ll mod){
	if(n==0) return 1;
	ll res=mod_pow(x*x%mod,n/2,mod);
	if(n&1) res=res*x%mod;
	return res;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll s;
	cin >> s;

	ll tmp=s;
	int keta=0;
	while(tmp>=1){
		keta++;
		tmp/=10;
	}
	ll ans=INF;
	rep(i,keta-2){
		ans = min(ans,abs(s%1000-753));
		s/=10;
	}
	cout << ans << "\n";


	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<ctype.h>
int main()
{
	char ch,ch2;

	while (1){
		scanf("%c", &ch);
		if (islower(ch))ch2=toupper(ch);
		else if (isupper(ch))ch2=tolower(ch);
		else ch2 = ch;
		putchar(ch2);
		if (ch == '\n') break;
	}
	return 0;
}

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

using namespace std;

using int64 = long long;

constexpr int SIZE = 110000;

// Does coordinate compression.
// Arguments:
// - raw_xs: Values to compress.
// Returns:
// - xs: Compressed values.
// - to_raw: A mapping from a compressed value to a raw value.
// Verified: CF573Div1D
tuple<vector<int>, vector<int>> Compress(const vector<int>& raw_xs) {
  unordered_set<int> raw_x_set(raw_xs.begin(), raw_xs.end());
  vector<int> to_raw(raw_x_set.begin(), raw_x_set.end());
  sort(to_raw.begin(), to_raw.end());
  unordered_map<int, int> to_index;
  for (int i = 0; i < to_raw.size(); i++) {
    to_index[to_raw[i]] = i;
  }
  vector<int> xs;
  for (int raw_x : raw_xs) {
    xs.push_back(to_index[raw_x]);
  }
  return make_tuple(xs, to_raw);
}

struct Edge {
  int from, to;
};

vector<vector<int>> ConnectedComponents(const vector<vector<Edge>>& graph) {
  int n = graph.size();
  vector<vector<int>> components;
  vector<int> visited(n);

  function<void(int)> dfs = function<void(int)>([&] (int v) {
    if (visited[v]) return;
    visited[v] = true;
    components[components.size() - 1].push_back(v);
    for (auto e : graph[v]) {
      if (visited[e.to]) continue;
      dfs(e.to);
    }
  });

  for (int s = 0; s < n; s++) {
    if (visited[s]) continue;
    components.push_back(vector<int>());
    dfs(s);
  }
  return components;
}

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

  int n;
  cin >> n;
  vector<int> raw_xs(n), raw_ys(n);
  for (int i = 0; i < n; i++) {
    cin >> raw_xs[i];
    cin >> raw_ys[i];
  }
  vector<int> xs, to_raw_xs, ys, to_raw_ys;
  tie(xs, to_raw_xs) = Compress(raw_xs);
  tie(ys, to_raw_ys) = Compress(raw_ys);

  int x_size = to_raw_xs.size();
  int y_size = to_raw_ys.size();
  vector<vector<Edge>> graph(x_size + y_size);
  for (int i = 0; i < n; i++) {
    int v1 = xs[i];
    int v2 = ys[i] + x_size;
    graph[v1].push_back(Edge({v1, v2}));
    graph[v2].push_back(Edge({v2, v1}));
  }
  // cout << "HOGE 1" << endl;
  vector<vector<int>> components = ConnectedComponents(graph);
  // cout << "HOGE 2" << endl;
  int64 count = 0;
  for (const auto& component : components) {
    int64 left_count = count_if(
        component.begin(), component.end(),
        [x_size] (int i) { return i < x_size; });
    int64 right_count = component.size() - left_count;
    count += left_count * right_count;
  }
  int64 answer = count - n;
  cout << answer << endl;
}


Measured memory_bytes: 11912
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1e9+7;
const ll INF = 1e18;
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)

/*
// 素集合データ構造
struct UnionFind
{
  // par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
  vector<int> par;
  // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
  vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1) {
    // 最初は全てのデータiがグループiに存在するものとして初期化
    rep(i,n) par[i] = i;
  }

  // データxが属する木の根を得る
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
  }

  // 2つのデータx, yが属する木をマージする
  void unite(int x, int y) {
    // データの根ノードを得る
    x = find(x);
    y = find(y);

    // 既に同じ木に属しているならマージしない
    if (x == y) return;

    // xの木がyの木より大きくなるようにする
    if (sizes[x] < sizes[y]) swap(x, y);

    // xがyの親になるように連結する
    par[y] = x;
    sizes[x] += sizes[y];
    // sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
  }

  // 2つのデータx, yが属する木が同じならtrueを返す
  bool same(int x, int y) {
    return find(x) == find(y);
  }

  // データxが含まれる木の大きさを返す
  ll size(ll x) {
    return sizes[find(x)];
  }
};
*/

struct UnionFind {
    //自身が親であれば、その集合に属する頂点数に-1を掛けたもの
    //そうでなければ親のid
    vector<int> r;
 
    UnionFind(int N) {
        r = vector<int>(N, -1);
    }
 
    int root(int x) {
        if (r[x] < 0) return x;
        return r[x] = root(r[x]);
    }
 
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (r[x] > r[y]) swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }
 
    ll size(int x) {
        return -r[root(x)];
    }
};

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll n, m;
  cin >> n >> m;
  UnionFind tree(n);
  ll ans = 0;
  rep(i,m) {
    ll x, y;
    cin >> x >> y;
    tree.unite(x-1,y-1);
  }
  rep(i,n) {
    ans = max(ans, tree.size(i));
  }
  cout << ans << '\n';

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

Measured memory_bytes: 4012
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
signed main()
{
    SPEED;
    int n,k,s;
    cin>>n>>k>>s;
    for(int i=0;i<k;i++)
    {
        cout<<s<<" ";
    }
    for(int i=k;i<n;i++)
    {
      if(s+1<=1e9)
        cout<<s+1<<" ";
      else
        cout<<s-1<<" ";
    }
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <iostream>
#include <functional>
#include <vector>
#include <stdio.h>
#include <queue>
#include <string.h>
#include <math.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define rep1(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)
#define per1(i,a,n) for (int i=a;i>n;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define endl "\n"
#define pi 3.14159265358979323846264338327950288419716939937510
#define IOS cin.sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll mod=1000000007;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll qpow(ll a,ll b){ll s=1;while(b>0){if(b%2==1){s=s*a;}a=a*a;b=b>>1;}return s;}
ll qpowmod(ll a, ll b, ll c){ll res, t;res=1;t=a%c;while(b){if(b & 1){res=res*t%c;}t=t*t%c;b>>=1;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline long long read(){long long k=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}return k*f;}
inline void write(long long x){if(x<0)x=-x,putchar('-');if(x>9)write(x/10);putchar(x%10+'0');}
// head
ll n,a[200005],ans;
map<ll,ll> m,v;
int main()
{
    //IOS;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        m[a[i]]++;
    }
    for(int i=1;i<=n;i++)
    {
        if(v[a[i]]==0)
        {
            ans+=(m[a[i]]*(m[a[i]]-1)/2);
            v[a[i]]++;
        }
    }
    for(int i=1;i<=n;i++)
    {
        cout<<ans-(m[a[i]]*(m[a[i]]-1)/2)+((m[a[i]]-1)*(m[a[i]]-2)/2)<<endl;
    }
    return 0;
}
/*

*/


Measured memory_bytes: 18944
K,A,B = map(int,input().split())
bis = 0
if abs(A-B) <= 1:
    print(K + 1)
elif A > B:
    print(K + 1)
else:
    K = K - A -1
    bis += B
    bis += K // 2 * B - K // 2 * A 
    print(bis + K % 2)
        



Measured memory_bytes: 2940
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll r, g, b;
  cin >> r >> g >> b;
  ll num = 100 * r + 10 * g + b;
  if (num % 4 == 0) {
    cout << "YES" << endl;
  } else
    cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 3616
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<string>
#include<ctype.h>
#include<math.h>
#include<set>
#include<map>
#include<vector> 
#include<queue>
#include<bitset>
#include<algorithm>
#include<time.h>
using namespace std;
void fre() { freopen("c://test//input.in", "r", stdin); freopen("c://test//output.out", "w", stdout); }
#define MS(x, y) memset(x, y, sizeof(x))
#define ls o<<1
#define rs o<<1|1
typedef long long LL;
typedef unsigned long long UL;
typedef unsigned int UI;
template <class T1, class T2>inline void gmax(T1 &a, T2 b) { if (b > a)a = b; }
template <class T1, class T2>inline void gmin(T1 &a, T2 b) { if (b < a)a = b; }
const int N = 105, M = 0, Z = 1e9 + 7, inf = 0x3f3f3f3f;
template <class T1, class T2>inline void gadd(T1 &a, T2 b) { a = (a + b) % Z; }
int casenum, casei;
int n;
char s[N];
int main()
{
	while (~scanf("%s", s))
	{
		int n = strlen(s);
		int pos = -1;
		for (int i = 0; i < n; ++i)
		{
			if (!strcmp(s + i, "FESTIVAL"))
			{
				pos = i;
			}
		}
		s[pos] = 0;
		puts(s);
	}
	return 0;
}
/*
【trick&&吐槽】


【题意】


【分析】


【时间复杂度&&优化】


【数据】


*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}
const int INF = 1e18;

signed main() {
    int N;
    cin >> N;
    vi A(N);
    rep(i, N) {
        cin >> A[i];
        if(A[i]==0) {
            cout << 0 << endl;
            return 0;
        }
    }

    int res = 1;
    rep(i, N) {
        int a = A[i];
        if(INF/res < A[i]) {
            cout << -1 << endl;
            return 0;
        }
        res *= a;
    }

    cout << res << endl;


    return 0;
}

Measured memory_bytes: 4052
<?php
  fscanf(STDIN,"%d", $N);
 $i=0;
 $ans =0;
  $array= array();
    while($N> 0){
      fscanf(STDIN, "%s", $s);
      $array[$i] = $s;
      if($i!=0){
        for($j=0 ; $j<$i ; $j++){
          if($s == $array[$j]){
            $ans = 0;
            break 2;
          }
        }
        if(substr($array[$i-1], -1,1) != substr($array[$i], 0 ,1)){
          $ans = 0;
          break;
        }else{
          $ans = 1;
        }
      }
      $N--;
      $i++;
    }
  if($ans==1) echo "Yes";
  else echo "No";
 ?>


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

int main() {
  
  int A, B, C, x1, x2, x3;
  cin >> A >> B >> C;
  
  x1 = max(A,max(B,C));
  x3 = min(A,min(B,C));
  x2 = A+B+C-(x1+x3);

  cout << x2*x3/2 << endl;
  
}

Measured memory_bytes: 3644
#include<stdio.h>
int main()
{
	int P,Q,R;
	scanf("%d %d %d",&P,&Q,&R);
	if(P+Q<P+R&&P+Q<Q+R){
		printf("%d",P+Q);
	}else if(P+R<Q+R){
		printf("%d",P+R);
	}else{
		printf("%d",Q+R);
	}
}

Measured memory_bytes: 128
#include <stdio.h>

int Cost(int N, int s, int a[N]){
  int i, cost;
  cost = 0;
  for(i = 0;i < N;i++) cost += (s - a[i]) * (s - a[i]);
  return cost;
}

void Do(int N){
  int i, s;
  int a[N];
  double S;
  S = 0;
  for(i = 0;i < N;i++){
    scanf("%d", &a[i]);
    S += a[i];
  }
  S /= N;
  if(S - (int) S >= 0.5) s = (int) S + 1;
  else s = (int) S;
  printf("%d\n", Cost(N, s, a));
}

int main(void){
  int N;
  scanf("%d", &N);
  Do(N);
  return 0;
}

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

using namespace std;

const int MAX = 1e5;
const int INF = 2e9;
typedef long long ll;


template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
    for (int i = 0; i < (int) v.size(); i++) {
        os << v[i] << (i + 1 != v.size() ? " " : "");
    }
    return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
    for (T &in : v) is >> in;
    return is;
}


int x, y, ca, cb, cc;

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

    cin >> x >> y >> ca >> cb >> cc;

    vector<int> A(ca);
    vector<int> B(cb);
    vector<int> C(cc);

    cin >> A >> B >> C;
    sort(A.rbegin(), A.rend());
    sort(B.rbegin(), B.rend());

    while (A.size() > x) A.pop_back();
    while (B.size() > y) B.pop_back();

    vector<int> merged{A};
    for (int i = 0; i < B.size(); ++i)
    {
        merged.emplace_back(B[i]);
    }

    sort(merged.begin(), merged.end());
    sort(C.rbegin(), C.rend());

    ll add = 0;
    for (int i = 0; i < cc && i < merged.size(); ++i)
    {
        if (C[i] > merged[i]) add += C[i] - merged[i];
    }

    ll ans = accumulate(merged.begin(), merged.end(), add);
    cout << ans;

    return 0;
}


Measured memory_bytes: 2176
S = input()

total = 0

for i in range(len(S)):
    if (i % 2) == 0:
        if (S[i] == 'R') or (S[i] == 'U') or (S[i] == 'D'):
            pass
        else:
            total += 1
    else:
        if (S[i] == 'L') or (S[i] == 'U') or (S[i] == 'D'):
            pass
        else:
            total += 1

if total == 0:
    print('Yes')
else:
    print('No')

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

using namespace std;

int main(void){
  int w,costs=4280;
  while(scanf("%d",&w) && w+1){
    costs=4280;
    do{
      if(w<=10){
	w=0;
	costs-=1150;
      }else if(w<=20){
	costs-=(w-10)*125;
	w=10;
      }else if(w<=30){
	costs-=(w-20)*140;
	w=20;
      }else{
	costs-=(w-30)*160;
	w=30;
      }
    }while(w>0);
    cout<<costs<<endl;
  }
  return 0;
}

Measured memory_bytes: 1208
A = str(input())
B = str(input())
C = str(input())
D = str(input())
E = str(input())
a = int(A[-1:])
b = int(B[-1:])
c = int(C[-1:])
d = int(D[-1:])
e = int(E[-1:])
F = [a,b,c,d,e]
G = F.count(0)
H = (10-a)+(10-b)+(10-c)+(10-d)+(10-e)
p = 9 if a == 0 else a
q = 9 if b == 0 else b
r = 9 if c == 0 else c
s = 9 if d == 0 else d
t = 9 if e == 0 else e
I = min([p,q,r,s,t])
J = int(A) +int(B) +int(C) + int(D) + int(E)
K = I -10*G -10
if G==5:
  print(J)
else:
  print(H+J+K)

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
vector<int> E[2][101010];
int P[2][101010];
int R[2];
int X[101010];

vector<int> E2[101010];
int L[2][101010];

void dfs(int id,int cur) {
	int pre=-1;
	FORR(e,E[id][cur]) {
		dfs(id,e);
		if(pre==-1) {
			pre=L[id][e];
		}
		else {
			E2[pre].push_back(L[id][e]);
			E2[L[id][e]].push_back(pre);
			pre=-1;
		}
	}
	
	if(pre!=-1) L[id][cur]=pre;
	else L[id][cur]=cur;
	
}

void dfs2(int cur,int v) {
	if(X[cur]!=2) {
		assert(X[cur]==v);
		return;
	}
	
	X[cur]=v;
	FORR(e,E2[cur]) dfs2(e,-v);
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,2) {
		FOR(j,N) {
			cin>>P[i][j+1];
			if(P[i][j+1]==-1) P[i][j+1]=0;
			E[i][P[i][j+1]].push_back(j+1);
		}
	}
	N++;
	FOR(i,N) {
		if(E[0][i].size()%2 != E[1][i].size()%2) return _P("IMPOSSIBLE\n");
		if(E[0][i].size()%2==0) X[i]=2;
	}
	dfs(0,0);
	dfs(1,0);
	
	FOR(i,N) if(X[i]==2) dfs2(i,1);
	_P("POSSIBLE\n");
	for(i=1;i<N;i++) _P("%d%c",X[i],(i==N-1)?'\n':' ');
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 18176
// Problem : C - Vacation
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define  maxn 100000
ll dp[maxn+1][3]; ll a[maxn+1][3]; ll n;
//memset(dp,-1,sizeof dp);

ll fun(ll idx,ll last){
	if(dp[idx][last]>-1) return dp[idx][last];
	if(idx>=n) return 0;
	ll ans=INT_MIN;
	for(ll i=0;i<3;i++){
		if(i==last) continue;
		ans=max(ans,a[idx][i]+fun(idx+1,i));
	}
	dp[idx][last]=ans;
	return dp[idx][last];
}

int main(){
	fast
	cin>>n;
	for(ll i=0;i<n;i++) {cin>>a[i][0]>>a[i][1]>>a[i][2];}
	ll ans=INT_MIN;
	memset(dp,-1,sizeof(dp));
	for(ll i=0;i<3;i++){
		ans=max(ans,a[0][i]+fun(1,i));
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 12800
#include<iostream>
#include<cstdlib>
#include <cmath>
#include<algorithm>
#include<vector>
#include<string>
#include<unordered_map>
#include <bits/stdc++.h>
using namespace std;

int main()
{ 
    long n, d, count = 0;
    cin >> n >> d;

    double x, y;

    for(int i=0; i<n; i++){
        cin >> x >> y;

        double distance = x*x + y*y;

        count += distance <= d*d;
    }
    
    cout << count << endl;
}


Measured memory_bytes: 3780
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws InterruptedException {
		FastScanner fs=new FastScanner();
		int n=fs.nextInt();
		int k=fs.nextInt();
		int[] a=fs.readArray(n);
		int min=1, max=(int)1e9+100;
		while (min!=max) {
			int mid=(min+max)/2;
			if (possible(mid, a, k)) {
				max=mid;
			}
			else {
				min=mid+1;
			}
		}
		System.out.println(min);
	}
	
	static boolean possible(int ans, int[] a, int k) {
		for (int i:a) {
			k-=(i+ans-1)/ans-1;
		}
		return k>=0;
	}
	
	void sort(int[] a) {
		ArrayList<Integer> list=new ArrayList<>();
		for (int i:a) list.add(i);
		Collections.sort(list);
		for (int i=0; i<a.length; i++) a[i]=list.get(i);
	}
	
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		public String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
			
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
		
		public long[] readLongArray(int n) {
			long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextLong();
			return a;
		}
	}

}


Measured memory_bytes: 55340
import bisect

S=[]

def insert(S,count,x):
    y=bisect.bisect_left(S,x)
    if y>=count or S[y]!=x:
        S.insert(y,x)
        count+=1
    print(count)
    return S,count

def find(S,x):
    y=bisect.bisect_left(S,x)
    if y<count and S[y]==x:
        judge=1
    else:
        judge=0
    return judge,y

def erase(S,count,x):
    judge,y=find(S,x)
    if judge==1:
        S.pop(y)
        count-=1
    return S,count

def dump(S,L,R):
    s=bisect.bisect_left(S,L)
    e=bisect.bisect_right(S,R)
    if e-s>0:
        print('\n'.join(map(str,S[s:e])))

q=int(input())
count=0
for i in range(q):
    query=list(map(int,input().split()))
    
    if query[0]==0:
        S,count=insert(S,count,query[1])
    elif query[0]==1:
        print(find(S,query[1])[0])
    elif query[0]==2:
        S,count=erase(S,count,query[1])
    else:
        dump(S,query[1],query[2])



Measured memory_bytes: 26396
w,a,b = map(int,input().split())
ans = 0
if b > a:
    if a + w < b:
        ans = b - (a + w)
    else:
        ans = 0
else:
    if b + w > a:
        ans = 0
    else:
        ans = a - (b + w)

print(ans)


Measured memory_bytes: 2940