akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<functional>
using namespace std;
int main() {
	int n;
	bool a[21][21];
	while (cin >> n&&n != 0) {
		for (int i = 0; i <= 20; i++) {
			for (int j = 0; j <= 20; j++) a[i][j] = false;
		}
		int c, d;
		for (int i = 0; i<n; i++) {
			cin >> c >> d;
			a[c][d] = true;
		}
		int sum = n, m;
		int x = 10, y = 10;
		cin >> m;
		char g;
		for (int i = 0; i<m; i++) {
			cin >> g >> c;
			int e=0, f=0;
			int x2 = x, y2 = y;
			if (g == 'N') {
				y += c;
				f = 1;
			}
			else if (g == 'S') {
				y -= c;
				f = -1;
			}
			else if (g == 'E') {
				x += c;
				e = 1;
			}
			else {
				x -= c;
				e = -1;
			}
			int j = y2, i2 = x2;
			for (;;) {
				if (i2 == x&&j == y) break;
				if (a[i2][j]) {
					sum--;
					a[i2][j] = false;
				}
				j += f;
				i2 += e;
			}
			if (a[x][y]) {
				sum--;
				a[x][y] = false;
			}
		}
		if (sum == 0) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

Measured memory_bytes: 3076
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) { if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(DUMPALL_ITR, (q).size()) { cerr << (q)[DUMPALL_ITR] << (DUMPALL_ITR == DUMPALL_ITR_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    // インタラクティブ問題では除去した方がいいかも
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll n, k; cin >> n >> k;
    vector<ll> x(n);
    REP(i, n) cin >> x[i];

    ll ans = INF;
    REP(i, n) {
        ll j = i + k - 1;
        if (j < n) {
            chmin(ans, abs(x[i]) + abs(x[i] - x[j]));
            chmin(ans, abs(x[j]) + abs(x[i] - x[j]));
        }
    }
    cout << ans << endl;
    
}

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

int solve(long long n){
    int res = sz(to_string(n));
    for(long long a = 1; a*a <= n; a++){
        if(n%a==0){
            ll b = n/a;
            res = min(res,max(sz(to_string(a)), sz(to_string(b))));
        }
    }
    return res;
}

int main(){
  ll n;
  cin >> n;
  cout << solve(n) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
vector<vector<int>> d(200005);
vector<int> value(200005);

void dfs(int x,int p){
    for(auto np:d[x]){
        if(np==p)continue;
        value[np]+=value[x];
        dfs(np,x);
    }
}

int main(){
    int n,q;cin>>n>>q;
    for(int i=0;i<n-1;i++){
        int a,b;cin>>a>>b;
        a--;b--;
        d[a].push_back(b);
        d[b].push_back(a);
    }
    for(int i=0;i<q;i++){
        int p,x;cin>>p>>x;
        p--;
        value[p]+=x;
    }
    dfs(0,-1);
    for(int i=0;i<n;i++)cout<<value[i]<<endl;
}

Measured memory_bytes: 24320
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int count = 0;
		for(int i = 0;i < 10;i++){
			int n = in.nextInt();
			count = count + n;
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 17320
N,K=1407,38
print(N,K)
P=0
ANS=[]
for i in range(K):
  P=[]
  P.append(1)
  for j in range(i*(K-1)+2,i*(K-1)+K+1):
    P.append(j)
  print(*P)
  ANS.append(set(P))
def f(R):
  Q=R[:]
  for i in range(len(Q)):
    Q[i]=Q[i]+i*(K-1)+2
  return Q
for i in range(2,K+1):
  X=[0]*K
  for j in range(K-1):
    X[j+1]=(X[j+1]+(i-2)*j)%(K-1)
  X[0]=i-2
  for j in range(K-1):
    print(*f(X))
    ANS.append(set(f(X)))
    for k in range(1,K):
      X[k]=(X[k]+1)%(K-1)

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

using namespace std;

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

  vector<char> v_s, v_t;
  for(int i = 0;
      i < s.length();
      ++i)
    {
      v_s.push_back(s[i]);
    }

  for(int i = 0;
      i < t.length();
      ++i)
    {
      v_t.push_back(t[i]);
    }

  sort(v_s.begin(), v_s.end());
  sort(v_t.begin(), v_t.end(), greater<char>());


  for(int i = 0;
      i < s.length()
        && i < t.length();
      ++i)
    {
      if(v_s[i] < v_t[i])
        {
          cout << "Yes" << endl;
          return 0;
        }
      else if (v_s[i] > v_t[i])
        {
          cout << "No" << endl;
          return 0;
        }
    }

  if(s.length() < t.length())
    {
      cout << "Yes" << endl;
    }
  else
    {
      cout << "No" << endl;
    }
  return 0;
}


Measured memory_bytes: 256
/*
Date: 2017/01/07 19:53:24 Saturday
*/
#include<bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define rep(i,a,n) for(int i=(a);i<=(n);++i)
#define dep(i,a,n) for(int i=(a);i>=(n);--i)
#define eps 1e-8
#define pi 3.1415926535897
#define sqr(x) ((x)*(x))
#define MAX(a,b) a=max(a,b)
#define MIN(a,b) a=min(a,b)
#define SZ(x) ((int)(x).size())
#define CPY(a,b) memcpy(a,b,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define POSIN(x,y) (1<=(x)&&(x)<=n&&1<=(y)&&(y)<=m)
#define all(x) (x).begin(),(x).end()
#define COUT(S,x) cout<<fixed<<setprecision(x)<<S<<endl
#define buli(x) (__builtin_popcountll(x))
#define bur0(x) (__builtin_ctzll(x))
#define bul2(x) (63-__builtin_clzll(x))
#define pw(x) ((ll(1))<<(x))
#define upmo(a,b) (((a)=((a)+(b))%mo)<0?(a)+=mo:(a))
#define mmo(a,b) (((a)=1ll*(a)*(b)%mo)<0?(a)+=mo:(a))
#define y0 y0z
#define y1 y1z
#define yn ynz
#define j0 j0z
#define j1 j1z
#define jn jnz
#define tm tmz
#ifdef LOCAL
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...) 
#endif
typedef long long ll;
typedef double lf;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<lf,lf> pff;
typedef complex<double> CD;
const int inf=0x3f3f3f3f;
const int mo=1000000007;
inline void gn(long long&x){
	int sg=1;char c;while(((c=getchar())<'0'||c>'9')&&c!='-');c=='-'?(sg=-1,x=0):(x=c-'0');
	while((c=getchar())>='0'&&c<='9')x=x*10+c-'0';x*=sg;
}
inline void gn(int&x){long long t;gn(t);x=t;}
inline void gn(unsigned long long&x){long long t;gn(t);x=t;}
inline void gn(double&x){double t;scanf("%lf",&t);x=t;}
inline void gn(long double&x){double t;scanf("%lf",&t);x=t;}
template<class T1,class T2>inline void gn(T1&r,T2&s){gn(r),gn(s);}
template<class T1,class T2,class T3>inline void gn(T1&r,T2&s,T3&t){gn(r),gn(s),gn(t);}
template<class T1,class T2,class T3,class T4>inline void gn(T1&r,T2&s,T3&t,T4&u){gn(r),gn(s),gn(t),gn(u);}
inline void gs(char *s){scanf("%s",s);}
inline void gc(char &c){while((c=getchar())>126 || c<33);}
inline void pc(char c){putchar(c);}
const int DX[]={1,0,-1,0},DY[]={0,1,0,-1};
ll powmod(ll a,ll b) {ll res=1;a%=mo;for(;b;b>>=1){if(b&1)res=res*a%mo;a=a*a%mo;}return res;}
ll powmod(ll a,ll b,ll mo) {ll res=1;a%=mo;for(;b;b>>=1){if(b&1)res=res*a%mo;a=a*a%mo;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
//*******************************************

const int N=111111,M=111111;
int l,m,n,t,C,x,y,xx,yy;
int main(){
#ifdef LOCAL
	freopen("C.in","r",stdin);//freopen("C.out","w",stdout);
#endif
	scanf("%d%d%d%d",&x,&y,&xx,&yy);
	x=xx-x;
	y=yy-y;
	rep(i,1,x)pc('R');
	rep(i,1,y)pc('U');
	rep(i,1,x)pc('L');
	rep(i,1,y)pc('D');
	pc('D');
	rep(i,1,x+1)pc('R');
	rep(i,1,y+1)pc('U');
	pc('L');
	pc('U');
	rep(i,1,x+1)pc('L');
	rep(i,1,y+1)pc('D');
	pc('R');
	return 0;
}

Measured memory_bytes: 384
from math import log10
from bisect import bisect_left
n=int(input())
l=[[0,0]]+[list(map(int,input().split()))for _ in range(n)]
for i in range(1,n+1):
  l[i][1]=log10(1-l[i][1]/10)
for i in range(n):
  l[i+1][1]+=l[i][1]
q=int(input())
for _ in range(q):
  a,b=map(int,input().split())
  i=bisect_left(l,[a,0])-1
  j=bisect_left(l,[b,0])-1
  p=l[j][1]-l[i][1]+9
  print(10**p)


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

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; i++) cin >> a[i];
	
	sort(a, a + n, greater<int>{});
	long long ans = a[0];
	for (int i = 1; i <= n/2 - 1; i++) {
		ans += 2ll*a[i];
	}
	if (n&1) ans += a[n/2];
	cout << ans;
}

Measured memory_bytes: 4420
#include <iostream>
using namespace std;
typedef long long ll;

int main() {
  ll H, N; cin >> H >> N;
  int sum = 0;
  for(int i = 0; i < N; i++) {
    int a; cin >> a;
    sum += a;
  }
  if(H <= sum) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

namespace _0020
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            List<string> list = new List<string>();
            for (int i = 0; i < str.Length; ++i)
            {
                list.Add(str.Substring(i, 1));
            }
            for(int i = 0; i < list.Count; ++i)
            {
                if(list[i] == " "|list[i] == ".")
                {
                    list[i] = list[i];
                }
                else
                {
                    list[i] = list[i].ToUpper();
                }
            }
            foreach(var item in list)
            {
                Console.Write(item);
            }
            Console.WriteLine();
        }
    }
}



Measured memory_bytes: 15804
def inv(a,m):
    b=m
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return lastx % m

mod=998244353
n,m,k=map(int,input().split())
frac=[1];frac_inv=[1]
beki=m
ans=0

for i in range(1,n+1):
    frac.append(frac[-1]*i%mod)
    frac_inv.append(inv(frac[-1],mod))

for i in range(n-k-1):
    beki=beki*(m-1)%mod
for i in range(n-k,n+1):
    ans+=beki*frac[n-1]*frac_inv[n-i]*frac_inv[i-1]%mod
    beki=beki*(m-1)%mod
print(ans%mod)

Measured memory_bytes: 96144
import math
import heapq

(n, m) = map(int, input().split())
a = []
for a_i in input().split():
    heapq.heappush(a, -1 * int(a_i))

for i in range(m):
    a_i = heapq.heappop(a)
    heapq.heappush(a, a_i / 2)

sum = 0
for a_i in a:
    sum += int(-1 * a_i)
print(sum)


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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define Sort(x) sort(x.begin(), x.end())
#define Sort_rev(x) sort(x.begin(), x.end(), greater<int>())
#define ALL(v) (v).begin(), (v).end()

//π M_PI
//deg = rad*180/M_PI

int main() {
    int n;
    cin >> n;
    int p[n], q[n];
    rep(i, n) {
        cin >> p[i];
    }
    rep(i, n) {
        cin >> q[i];
    }

    std::vector<ll> v;
    rep(i, n) {
        v.push_back(i+1);
    }

    int ii = 1;
    int a = 0;
    int b = 0;
    do {
        int k = 0;
        int l = 0;
        rep(i, n) {
            if ( v[i] == p[i] && a == 0 ) {
                k++;
            }
            if ( v[i] == q[i] && b == 0 ) {
                l++;
            }
        }
        if ( k == n ) {
            a = ii;
        }
        if ( l == n ) {
            b = ii;
        }
        ii++;
    } while(next_permutation(ALL(v)));
    cout << abs(a-b) << endl;
    return 0;
}


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

constexpr int MAX_N = 1e5+7;
enum {A, B, C};
int a[MAX_N], b[MAX_N], c[MAX_N];
int dp[MAX_N][3];

int main() {
  int N;
  cin >> N;
  for (int i{1}; i <= N; ++i) {
    cin >> a[i] >> b[i] >> c[i];
  }

  for (int i{1}; i <= N; ++i) {
    dp[i][A] = max(dp[i-1][B] + a[i], dp[i-1][C] + a[i]);
    dp[i][B] = max(dp[i-1][C] + b[i], dp[i-1][A] + b[i]);
    dp[i][C] = max(dp[i-1][A] + c[i], dp[i-1][B] + c[i]);
  }

  cout << max(max(dp[N][A], dp[N][B]), dp[N][C]) << endl;
  return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>
#include<math.h>

int main(void) {
	int a, b;
	char op,sp;
	scanf("%d",&a);
	sp=getchar();
	op=getchar();
	sp=getchar();
	scanf("%d",&b);
	while(op!='?'){
		switch(op){
			case '+':printf("%d\n",a+b);
				break;
			case '-':printf("%d\n",a-b);
				break;
			case '*':printf("%d\n",a*b);
				break;
			case '/':printf("%d\n",a/b);
				break;
		}
		scanf("%d",&a);
	sp=getchar();
	op=getchar();
	sp=getchar();
		scanf("%d",&b);
	}
	

}

Measured memory_bytes: 1860
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    long long int k;
    cin >> n >> k;
    int p[n+5];
    p[0]=0;
    for(int i=1;i<=n;i++)cin >> p[i];
    long long int c[n+5];
    c[0]=0;
    for(int i=1;i<=n;i++)cin >> c[i];
    long long int ans= -1e18-5;
    for(int i=1;i<=n;i++){
        int next=i;
        long long int count=0;
        long long int tmp=0;
        long long int tmp_ans=0;
        long long int nokori;
        while((count==0) || (next!=i)){
            count++;
            tmp+=c[p[next]];
            if(count<=k)ans=max(ans,tmp);
            next=p[next];
        }
        tmp_ans=tmp*(k/count);
        nokori=k-((k/count)*count);
        long long int count2=0;
        if((k/count)>0)ans=max(ans,tmp_ans);
        while(count2<nokori){
            count2++;
            tmp_ans+=c[p[next]];
            next=p[next];
            ans=max(ans,tmp_ans);            
        }
        count2=0;
        if((k/count)>0){
            tmp_ans=tmp*((k/count)-1);
        while(count2<count){
            count2++;
            tmp_ans+=c[p[next]];
            next=p[next];
            ans=max(ans,tmp_ans);            
        }}
    }
    cout << ans;
}

Measured memory_bytes: 3688
#include <iostream>

#include <boost/range/irange.hpp> // boost::irange

using namespace std;
using boost::irange;

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

  double acc = 0.0;
  double price;
  string type;
  for (auto i: irange(0, n)) {
    cin >> price;
    cin >> type;
    acc += type == "JPY" ? price : price * 380000.0;
  }

  cout << acc << endl;

  return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import GHC.ST
-- import System.IO.Unsafe

-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
-- templete

hb r a = tjoin (hit, blow)
  where
    hit = length . filter id . zipWith (==) r $ a
    blow = length . filter (\(t,b) -> let ct = fromMaybe 0 $ snd <$> find ((==t) . fst) counts in if b then ct>=2 else ct>=1) $ zipWith (\ t t' -> (t', t==t')) r a
    counts = map (fnTuple (head, length)) . group . sort $ r


main = do
    [r,a] <- words <$> getLine
    unless (r=="0" && a=="0") $ putStrLn (hb r a) >> main


Measured memory_bytes: 3924
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cassert>

using namespace std;

const int N = 1e5 + 7;

int n;
vector<int> sons[N];

int dfs(int u) {
	vector<int> tmp;
	for (int v : sons[u]) {
		tmp.push_back(dfs(v));
	}
	sort(tmp.begin(), tmp.end());
	int ret = 0;
	for (int i = 0; i < tmp.size(); i++) {
		ret = max(ret, tmp[i] + (int)tmp.size() - i);
	}
	return ret;
}

int main() {
	scanf("%d", &n);
	for (int i = 2; i <= n; i++) {
		int fat;
		scanf("%d", &fat);
		sons[fat].push_back(i);
	}
	cout << dfs(1) << endl;
}


Measured memory_bytes: 13568
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int n,a[120][120],B;
int main(){
	while(true){
		cin>>n;
		if(n==0){break;}
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				cin>>a[i][j];
			}
		}
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				B=0;
				for(int k=0;k<n;k++){
					if(a[i][j]>a[i][k] || a[i][j]<a[k][j])B=1;
				}
				if(B==0){
					cout<<a[i][j]<<endl;goto E;
				}
			}
		}
		cout<<"0"<<endl;E:;
	}
	return 0;
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

template<typename T> void dump_array(const vector<T>& v) {
    int m = v.size();
    for_(i,0,m) cout << v[i] << (i<m-1 ? " " : "\n");
}

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

    scc_graph G(N);
    for_(i,0,M) {
        int a, b;
        cin >> a >> b;
        G.add_edge(a, b);
    }

    auto res = G.scc();
    cout << res.size() << endl;
    for (auto V : res) {
        int n = V.size();
        cout << n << " ";
        dump_array(V);
    }
}

Measured memory_bytes: 40088
use std::io::*;
use std::str::FromStr;
use std::convert::TryInto;

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

fn main() {
    let a: u32 = read();
    let b: String = read();

    let mut str1 = "".to_string();
    for (i, c) in b.chars().enumerate() {
        if i < a.try_into().unwrap() {
            str1.push(c);
        } else {
            str1.push_str("...");
            break;
        }
    }
    println!("{}", str1);
}


Measured memory_bytes: 2160
N = int(input())
H = list(map(int,input().split()))
ans=0
ans_list=[]
for i in range(N-1):
  if H[i]>= H[i+1]:
    ans +=1
  else:
    ans_list.append(ans)
    ans= 0
ans_list.append(ans)
    
    
print(max(ans_list))

Measured memory_bytes: 20344
#include<cstdio>
using namespace std;
int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	int s=(a+b)/2;
	if ((a+b)%2==0)
	{
		printf("%d\n",s);
	}
	else
	{
		printf("%d\n",s+1);
	}
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
#define maxn 200010
#define pb push_back
#define ll long long

int n,b[maxn];
struct point{int x,y,id;}a[maxn];
struct TREE{
	ll tr[maxn];
	void init(){for(int i=1;i<=n;i++)tr[i]=1e18;}
	void ch(int x,ll y){for(;x<=n;x+=(x&-x))tr[x]=min(tr[x],y);};
	ll ask(int x){ll re=1e18;for(;x;x-=(x&-x))re=min(re,tr[x]);return re;}
}tr;
int id[maxn];
bool cmp1(point x,point y){return x.x==y.x?x.y<y.y:x.x<y.x;}
bool cmp2(point x,point y){return x.x==y.x?x.y<y.y:x.x>y.x;}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d %d",&a[i].x,&a[i].y),b[i]=a[i].y;
	sort(b+1,b+n+1);
	for(int i=1;i<=n;i++)a[i].id=lower_bound(b+1,b+n+1,a[i].y)-b;
	sort(a+1,a+n+1,cmp1);ll ans=0;
	tr.init();for(int i=1;i<=n;i++){
//		printf("%d %d : ask : %lld\n",a[i].x,a[i].y,tr.ask(a[i].id));
		ans=max(ans,(ll)a[i].x+a[i].y-tr.ask(a[i].id));
		tr.ch(a[i].id,a[i].x+a[i].y);
	}
	sort(a+1,a+n+1,cmp2);
	tr.init();for(int i=1;i<=n;i++){
//		printf(" %d %d\n",a[i].x,a[i].y);
		ans=max(ans,(ll)a[i].y-a[i].x-tr.ask(a[i].id));
		tr.ch(a[i].id,a[i].y-a[i].x);
	}
	printf("%lld",ans);
}

Measured memory_bytes: 6428
#include <bits/stdc++.h>
using namespace std;
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = int(n); i >= 0; --i)
typedef long long LL;
typedef pair<int, int> PII;
  
void f(int a, int b, int k) {
  int small = a<b?a:b;
  int count = 0;
  int ans=0;

  forn(i, small){
  	if(a % i == 0 && b % i == 0){
      //cout << "i " << i << endl;
      count++;
    }
    if(count == k){
      ans = i;
      break;
    }
  }
  cout << ans << endl; 
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, k;
  cin >> a >> b >> k;
  f(a,b,k);
  return 0;
}

Measured memory_bytes: 3656
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

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

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;

typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<db,db> pd;

typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<db> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 
typedef vector<pd> vpd; 

#define mp make_pair
#define f first
#define s second
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend() 
#define rsz resize
#define ins insert 
#define ft front() 
#define bk back()
#define pf push_front 
#define pb push_back
#define eb emplace_back 
#define lb lower_bound 
#define ub upper_bound 

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MX  = 2e5+5; 
const int MOD = 1e9+7; // 998244353;
const ll  INF = 1e18; 
const ld  PI  = acos((ld)-1);

const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1};
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); 

template<class T> bool ckmin(T& a, const T& b) { 
	return b < a ? a = b, 1 : 0; 
}
template<class T> bool ckmax(T& a, const T& b) { 
	return a < b ? a = b, 1 : 0; 
} 

constexpr int pct(int x) { return __builtin_popcount(x); } // number of ones 
constexpr int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x)) 
template<class T> T cdiv(T a, T b) { return a/b+!(a<0||a%b == 0); } // division of a by b rounded up, assumes b > 0 

int fstTrue(function<bool(int)> f, int lo, int hi) {
	hi++; assert(lo <= hi); // assuming f is increasing
	while (lo < hi) { // find first index such that f is true 
		int mid = (lo+hi)/2; 
		f(mid) ? hi = mid : lo = mid+1; 
	} 
	return lo;
}

template<class T> void remDup(vector<T>& v) { 
	sort(all(v)); v.erase(unique(all(v)),end(v)); 
}

// DEBUG
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
	cerr << h; if (sizeof...(t)) cerr << ", ";
	DBG(t...); 
}
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)

// FILE I/O
void setIn(str S) { freopen(S.c_str(),"r",stdin); }
void setOut(str S) { freopen(S.c_str(),"w",stdout); }
void setIO(str S = "") {
	ios_base::sync_with_stdio(0); cin.tie(0); // fast I/O
	// cin.exceptions(cin.failbit); 
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(S)) { setIn(S+".in"), setOut(S+".out"); } // for USACO
}

int32_t main() { 
	
	setIO();

    int n; cin >> n;

    cout << (n >= 30 ? "Yes\n" : "No\n");

}	

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

 
int main(){

  int N,x;
  cin>>N>>x;
  vector<int> num(N);
  for(int i=0; i<N; i++){
    cin>>num.at(i);
  }
  
  long long ans=0;
  if (num[0]>x){
    ans += num[0]-x;
    num[0] -= num[0]-x;
  }
  for(int i=0; i<N-1; i++){
    if(num[i]+num[i+1]>x){
         ans += (num[i]+num[i+1])-x;
         num[i+1] -= (num[i]+num[i+1])-x;
    }
  }
  cout<<ans<<endl;
  
 return 0; 
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
	ll n; cin >> n;
	ll si = 0, na = 1;
	bool f = 0;
	for(ll i = 0; i < n; ++i){
		ll a; cin >> a;
		if((ll)abs(a) > (ll)abs(si)){
			si = a;
			na = i + 1;
			f = a > 0;
		}
	}
	cout << 2 * n << endl;
	cout << na << " " << (f ? 1 : n) << endl;
	cout << na << " " << (f ? 1 : n) << endl;
	for(ll i = 1; i < n; ++i){
		cout << (f ? i : n + 1 - i) << " " << (f ? i + 1 : n - i) << endl;
		cout << (f ? i : n + 1 - i) << " " << (f ? i + 1 : n - i) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

int main(){

    bool ISa=0, ISb=0, ISc=0,f=0;

    char tmp;
    while(cin>>tmp){
        if(tmp=='a'){
            if(ISa){
                f = 1;
            }else{
                ISa = 1;
            }
        }
        if(tmp=='b'){
            if(ISb){
                f = 1;
            }else{
                ISb = 1;
            }
        }
        if(tmp=='c'){
            if(ISc){
                f = 1;
            }else{
                ISc = 1;
            }
        }
    }
    if(f){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 888
#include <algorithm>
#include <iostream>
#include <cstdio>
using namespace std;
int a[1000006];
int main(){
    int n; cin >> n;
    for (int i = 1; i <= n; ++ i){
        scanf("%d", &a[i]);
        a[i] -= i;
    }
    sort(a + 1, a + 1 + n);
    int m = n + 1 >> 1;
    long long ans = 0;
    for (int i = 1; i <= m; ++ i)
        ans += a[m] - a[i];
    for (int i = m + 1; i <= n; ++ i)
        ans += a[i] - a[m];
    cout << ans << endl;
}


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

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

  int ans = 0, ans1 = 0, ans2 = 0;
  for(auto c: N){
    ans1 += c - '0';
  }
  ans2 = (N[0] - '0' - 1) + (N.length() - 1) * 9;

  ans = max(ans1, ans2);

  cout << ans << endl;
  
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

lint col(lint n) {
    if (n % 2 == 0) {
        return n/2;
    }
    else {
        return 3 * n + 1;
    }
}

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

    lint i = 1;
    set<int> c;

    while (c.find(s) == c.end()) {
        c.insert(s);
        s = col(s);
        i++;
    }

    cout << i << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define pb push_back
#define fi first
#define se second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void chOut(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using v_bool = vector<bool>;
using v_Pii = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;



signed main(){

    int N; cin >> N;
    int ans = 0;
    FOR(a, 1, N){
        ans += (N - 1) / a;
    }
    Out(ans);

    return 0;
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

int N, M;
vector<int> adj[100005];
int step[100005];
int prv[100005];

int main() {
    cin >> N >> M;
    for_(i,0,M) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    queue<int> que;
    que.push(0);

    INIT(step, -1);
    INIT(prv, -1);
    step[0] = 0;

    while (!que.empty()) {
        int v = que.front(); que.pop();
        for (int u : adj[v]) {
            if (step[u] != -1) continue;
            que.push(u);
            step[u] = step[v] + 1;
            prv[u] = v;
        }
    }

    int f = *min_element(step, step + N);
    if (f == -1) puts("No");
    else {
        puts("Yes");
        for_(i,1,N) cout << prv[i] + 1 << endl;
    }
}

Measured memory_bytes: 10908
from collections import deque

h,w=list(map(int,input().split()))
s=[input() for _ in range(h)]

dp=[[1000]*(w+1) for _ in range(h+1)]

if s[0][0]=='.':
    dp[0][0]=0
else:
    dp[0][0]=1

for i in range(h):
    for j in range(w):
        if i-1>=0:
            dp[i][j]=dp[i-1][j]+(1 if s[i-1][j]=='.' and s[i][j]=='#' else 0)
        if j-1>=0:
            dp[i][j]=min(dp[i][j],dp[i][j-1]+(1 if s[i][j-1]=='.' and s[i][j]=='#' else 0))

print(dp[h-1][w-1])

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

int main() {
  int N, M, i; cin >> N >> M;
  vector<int> a(N);
  rep (i, N)
    cin >> a.at(i);
  sort(a.begin(), a.end(), greater<int>());
  int sum=0;
  sum = accumulate(a.begin(), a.end(), sum);
  bool can=false;
  i=0;
  while (a.at(i)*4*M >= sum) {
    if (i+1 >= M) {
      can = true;
      break;
    }
    i++;
  }
  if (can)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T> inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();
    
    int n, k;
    cin >> n >> k;

    n--;
    int sum = 1, ans = 1;
    while (1) {
        int num = sum / k + (bool)(sum % k);
        if (n < num)break;
        ans++;
        sum += num;
        n -= num;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 3192
while True:
    W,H = map(int,input().split())
    if W==0 and H==0:
        break
    for i in range(W):
        print("#"*H)
    print()
    

    
"""
EOL = '0 0'
stdin = [line for line in iter(input, EOL)]
lines = [map(int, line.split()) for line in stdin]

for H, W in lines:
    for i in range(H):
        print('#' * W)
    print()
"""


Measured memory_bytes: 5624
def Qc():
    x, k, d = map(int, input().split())
    x = abs(x)
    all_minus = abs(x) - (k * d)
    if 0 <= all_minus:
        ans = all_minus
    else:
        point = abs(all_minus) // d
        all_minus += d * point
        ans = abs(all_minus)
        if point % 2 != 0:
            ans = min(abs(all_minus - d), abs(all_minus + d))
    print(ans)


if __name__ == '__main__':
    Qc()


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

int main(){
  int a,b;
  char s[10],t[10],u[10];

  scanf("%s %s", s, t);
  scanf("%d %d", &a, &b);
  scanf("%s", u);

  if(strcmp(s,u) == 0) printf("%d %d\n", a - 1, b);

  else if(strcmp(t,u) == 0) printf("%d %d\n", a, b - 1);

  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        int a,b,c;
        //?´???°?????????????????°
        int count = 0;
    	//?¨??????\??????????????????????????§????????????
		Scanner scanner = new Scanner(System.in);
		
		a = scanner.nextInt();
    	b = scanner.nextInt();
    	c = scanner.nextInt();
    	
    	for(int i = a; i < b+1 ;i++){
    		if(c%i == 0){
    			count++;
    		}
    	}
    	
    	System.out.println(count);
    }
}	

Measured memory_bytes: 26124
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,s,f) for(i=s;i<f;i++)
#define hi cout<<'h'<<'i'<<'\n' 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
#define mod2 998244353
#define space 100005
//<<fixed << setprecision(9)

int main()
{
	int n,i,j,t;
	boost;

	cin>>n;
	int arr[n];
	ll ans=0;
	rep(i,0,n)cin>>arr[i];
	rep(i,0,n)
	{
		rep(j,i+1,n)ans+=arr[i]*arr[j];
	}
	cout<<ans;

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int n=0;
  n=s.size();
  if(n==1){
    cout<<stoi(s)<<endl;
    return 0;
  }
  long long ans=0;
  for(int i=0;i<(1<<(n-1));i++){
    int las=-1;
    bitset<10> bit(i);
    for(int j=0;j<n-1;j++){
      if(bit.test(j)){
        string sub=s.substr(las+1,j-las);
        ans+=stoll(sub);
        las=j;
      }
    }
    ans+=stoll(s.substr(las+1,n-1-las));
               }
               cout<<ans<<endl;
               }

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

int main(){
    int n;
    cin >> n;
    vector<pair<int,int>> a[20];
    rep(i,n){
        int ai;
        cin >> ai;
        rep(j,ai){
            pair<int,int> p;
            cin >> p.first >> p.second;
            p.first--;
            a[i].push_back(p);
        } 
    }
    int ans = 0;
    rep(i,pow(2,n)){
        int flag = 0;
        stringstream ss;
        ss << bitset<16>(i);
        string bit = ss.str();
        reverse(bit.begin(), bit.end());
        rep(j,bit.length()){
            int ibit = (int)bit[j]-48;
            if(ibit != 1) continue;
            //if(i ==4)cout<<"ZZZ"<<j;
            for ( auto& p: a[j] ){
                int iibit = bit[p.first]-48;
                if(iibit != p.second)
                        flag = 1;
            }
        }
        if(flag != 1){
            int c=0;
            rep(j,bit.length()){
                int ibit = (int)bit[j]-48;
                if(ibit == 1) c++;
            }
            ans = max(ans,c);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 384
/* ex5-3
   Sagzar1993  */

#include <stdio.h>
#define LIM 100 //行数、列数の上限

int main(void) {
    int row, col, i, j; //行と列の数
    //各行、各列について全てのマス目が白なら１、そうでなければ０
    int whiteRow[LIM] = {0}, whiteCol[LIM] = {0}; 
    char colors[LIM][LIM]; //記号の配列

    scanf("%d %d", &row, &col); //行数、列数の入力


    for(i = 0; i < row; i++){
        for(j = 0; j < col; j++){
            scanf(" %c", &colors[i][j]); //各マス目の色記号の入力
        }
    }


    for(i = 0; i < row; i++){
        for(j = 0; j < col; j++){
            if(colors[i][j] != '.'){
                break; //各行について、白でないマス目があれば終了して次の行へ
            }
        }
        if(j == col){
            whiteRow[i] = 1; //行の全てのマス目が白ならwhiteRowに1を保存
        }
    }
    
    for(j = 0; j < col; j++){
        for(i = 0; i < row; i++){
            if(colors[i][j] != '.'){
                break; //各列について、白でないマス目があれば終了して次の行へ
            }
        }
        if(i == row){
            whiteCol[j] = 1; //列の全てのマス目が白ならwhiteColに1を保存
        }
    }
    
    for(i = 0; i < row; i++){
        if(whiteRow[i] == 1){
            continue;  //各行について、whiteRowを参照し、その行の全てのマス目が白ならスキップ
        }

        for(j = 0; j < col; j++){
            if(whiteCol[j] == 1){
                continue; //各行の各列のマス目について、その列が全てのマス目が白である列ならスキップ
            }
            printf("%c", colors[i][j]); //そのマス目の行と列がともに全て白でないときは出力
        }
        printf("\n"); //各行について、全てのマス目を調べ終えたら改行
    }
    
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<map>
using namespace std;

int main(){
    int n;
    cin>>n;
    map<int,int> m;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    
    long long ans=0;
    for(int i=0;i<n;i++){
        int r=i-a[i];
        ans += m[r];
        int l=a[i]+i;
        m[l]++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 20940
import Control.Applicative
import Text.Printf

main :: IO ()
main = do
  n <- read <$> getLine :: IO Int
  xs <- (map read . words) <$> getLine
  putStrLn $ solve xs

solve :: [Int] -> String
solve xs = show (minimum xs) ++ " " ++ show (maximum xs) ++ " " ++ show (sum xs)

Measured memory_bytes: 11116
{-# LANGUAGE OverloadedStrings #-}
import Data.List
import Data.Ord
import Data.Char
import Data.Ratio
import Data.Maybe
import Data.String
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as BS
---------------------------------------------------------------------------------
main = do
  abk <- getIntListw'
  (putStrLn . unwords . map show . greedy) abk

greedy [a,b,0] = [a,b]
greedy [a,b,k]
  |a>=k = [a-k,b]
  |b>=k-a = [0,b-(k-a)]
  |otherwise = [0,0]


---------------------------------------------------------------------------------

{-ByteString関連-}
--IO
getLine' = BS.getLine
getContents' = BS.getContents
getInt' = fst . fromJust . BS.readInt <$> getLine'
getIntListw' = map (fst . fromJust. BS.readInt) .words' <$> getLine'
getIntListl' = map (fst . fromJust. BS.readInt) .lines' <$> getContents'
getInteger' = fst . fromJust. BS.readInteger <$> getLine'
putStr' = BS.putStr
putStrLn' = BS.putStrLn
--演算子
bs1 |++| bs2 = BS.append bs1 bs2
chr |:+| bs2 = BS.cons chr bs2
bs1 |+:| chr = BS.snoc bs1 chr
--部分文字列操作
head' bs = BS.head bs
last' bs = BS.last bs
init' bs = BS.init bs
tail' bs = BS.tail bs
take' n bs = BS.take n bs
drop' n bs = BS.drop n bs
takeWhile' f bs = BS.takeWhile f bs
dropWhile' f bs = BS.dropWhile f bs
--リスト操作
length' bs = BS.length bs
reverse' bs = BS.reverse bs
transpose' bs = BS.transpose bs
sort' bs = BS.sort bs
group' bs = BS.group bs
lines' bs = BS.lines bs
words' bs = BS.words bs
unlines' bs = BS.unlines bs
unwords' bs = BS.unwords bs
--要素の有無
elem' chr bs = BS.elem chr bs
notElem' chr bs = BS.notElem chr bs
elemIndex' chr bs = BS.elemIndex chr bs
elemIndices' chr bs = BS.elemIndices chr bs
count' chr bs = BS.count chr bs
--整形
--justifyRight'::Char -> ByteString -> ByteString
--justifyRight' chr bs = convertString $ T.justifyRight chr (convertString bs)

{-elem関連-}
--elemの第一引数をリストにしたもの。
--elemList "abc" "atcoder" -> [True,False,True]
elemList [] _ = []
elemList (x:xs) list  = elem x list : elemList xs list

--elemIndexの第一引数をリストにしたもの。
elemIndexList [] list = []
elemIndexList (x:xs) list  = elemIndex x list : elemIndexList xs list

--elemIndicesの第一引数をリストにしたもの。
elemIndicesList [] list = []
elemIndicesList (x:xs) list  = elemIndices x list : elemIndicesList xs list

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

using namespace std;

#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mmp make_pair
#define st first
#define nd second
#define rd third
#define ll long long
#define pii pair <int, int>
#define tri pair <pii, int>
#define itr pair <int, pii>
#define PQ priority_queue
#define all(v) (v).begin(), (v).end()
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, n) for (int (i) = (a); (i) < (int)(n); i++)
#define FORN(i, a, n) for (int (i) = (a); (i) > (int)(n); i--)
#define Rep(i, n) for (int (i) = 0; (i) <= (int)(n); i++)
#define For(i, a, n) for (int (i) = (a); (i) <= (int)(n); i++)
#define Forn(i, a, n) for (int (i) = (a); (i) >= (int)(n); i--)
#define FORD(i, n) for (int (i) = (int)(n) - 1; i>= 0; i--)
#define rep(i, n) for (int (i) = 1; (i) <= (int)(n); i++)
#define EACH(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)

#define DEBUG(x) cout << #x << " = " << (x) << endl;
#define PR(a, n) {cout << #a << " = "; FOR(_, 1, n) cout << a[_] << ' '; puts(""); }
#define PRO(a, n) { cout << #a << " = "; REP(_, n) cout << a[_] << ' '; puts(""); }
#define pi 3.1415926535897932384626433832795028841971
//#define LOCAL

const int INF = 1 << 30;
const int N = 1005;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};

inline ll read()
{
	ll x = 0; int f = 1, c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48);
	return x * f;
}

int n, k; 
vector <int> a; 

int main()
{
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	
	n = read(); k = read(); 
	REP(i, n) a.pb(read()); 
	
	int sum = 0; 
	REP(i, k) sum += a[i]; 
	float res = (float)(k + sum) / 2.0; 
	FOR(i, k, n)
	{
		sum += a[i] - a[i - k]; 
		if ((float)(k + sum) / 2.0 > res) res = (float)(k + sum) / 2.0; 
	}
	
	printf("%.12f", res); 
	
	return 0;
}


Measured memory_bytes: 1400
N,C = map(int,input().split(' '))
Xn = [ list(map(int,input().split(' '))) for n in range(N)]

pre_xn_sum = [ (Xn[0][1] - Xn[0][0]*2,0) ] # (s,max_idx)
post_xn_sum = []

def get_pre_xn_sum(distance=1):
    pre_xn_sum = [ (Xn[0][1] - Xn[0][0]*distance,0) ] # (s,max_idx)
    for i in range(1,N):
        cuurent_v = pre_xn_sum[i-1][0] + Xn[i][1] - ( Xn[i][0] - Xn[i-1][0] ) *distance
        previous_max_idx = pre_xn_sum[i-1][1]
        if pre_xn_sum[previous_max_idx][0] > cuurent_v:
            max_idx = previous_max_idx
        else:
            max_idx = i
        pre_xn_sum.append((cuurent_v,max_idx))
    return pre_xn_sum

def get_post_xn_sum(distance=1):
    post_xn_sum = [ (Xn[N-1][1] - (C-Xn[N-1][0])*distance,0) ] # (s,max_idx)
    for i in range(1,N):
        xn_i = N - 1 - i
        cuurent_v = post_xn_sum[i-1][0] + Xn[xn_i][1] - ( Xn[xn_i+1][0] - Xn[xn_i][0] ) *distance
        previous_max_idx = post_xn_sum[i-1][1]
        if post_xn_sum[previous_max_idx][0] > cuurent_v:
            max_idx = previous_max_idx
        else:
            max_idx = i
        post_xn_sum.append((cuurent_v,max_idx))
    return post_xn_sum

pre_xn_sum = get_pre_xn_sum(1)
pre_xn_sum_2 = get_pre_xn_sum(2)
post_xn_sum = get_post_xn_sum(1)
post_xn_sum_2 = get_post_xn_sum(2)

ans_1 = 0
ans_2 = 0

# pre_xn_sum && post_xn_sum_2
for i in range(N+1):
    x = i -1
    y = N - 1 - i
    tmp_ans = 0
    if x >= 0:
        x_max_idx = pre_xn_sum[x][1]
        x_max = pre_xn_sum[x_max_idx][0]
        tmp_ans += max(x_max,0)
    if y >= 0:
        y_max_idx = post_xn_sum_2[y][1]
        y_max = post_xn_sum_2[y_max_idx][0]
        tmp_ans += max(y_max,0) 
    ans_1 = max(ans_1,tmp_ans)

# pre_xn_sum && post_xn_sum_2
for i in range(N+1):
    x = i -1
    y = N - 1 - i
    tmp_ans = 0
    if x >= 0:
        x_max_idx = pre_xn_sum_2[x][1]
        x_max = pre_xn_sum_2[x_max_idx][0]
        tmp_ans += max(x_max,0)
    if y >= 0:
        y_max_idx = post_xn_sum[y][1]
        y_max = post_xn_sum[y_max_idx][0]
        tmp_ans += max(y_max,0) 
    ans_1 = max(ans_1,tmp_ans)

print(max(ans_1,ans_2))

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

int main() {
  long n,a,b,x=0,y=0,z=0,p;
  cin >> n >> a >> b;
  for(long i=0;i<n;i++) {
    cin >> p;
    if(p<=a) x++;
    else if(p<=b) y++;
    else z++;
  }
  cout << min(x,min(y,z)) << endl;
}

Measured memory_bytes: 256
#include <iostream>
const int MOD = 1000000007;
typedef long long ll;
using namespace std;

int main() {
	int n;
	cin >> n;
	ll ans = 1;
	for (int i = 1; i <= n; i++)
		ans = ans * i % MOD;
	cout << ans << endl;
	return 0;
}

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

int main(){
    ll h, w;
    cin >> h >> w;
    ll ans = h * w;
    if (h == 1 || w == 1) {
        cout << 1 << endl;
        return 0;
    }
    if (ans%2==0) {
        ans /= 2;
    } else {
        ans = (ans + 1)/ 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256