akhauriyash/Code-Regression huggingface dataset:
from collections import Counter
n=int(input())
s=[]
for _ in range(n):
    s.append(input())
c = Counter(s)
ans=[]
max_vote = max(c.values())
for i,j in c.items():
    if j == max_vote:
        ans.append(i)
print("\n".join(sorted(ans)))

Measured memory_bytes: 35952
package main

import (
	"fmt"
	"strings"
)

func main() {
	var H, N int
	fmt.Scanf("%d %d\n", &H, &N)

	A := make([]string, N)
	B := make([]string, H)
	for i := 0; i < N; i++ {
		A[i] = fmt.Sprint(H)
	}
	for i := 0; i < H; i++ {
		B[i] = fmt.Sprint(N)
	}
	AS := strings.Join(A, "")
	BS := strings.Join(B, "")
	if AS > BS {
		fmt.Println(BS)
	} else {
		fmt.Println(AS)
	}

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 1000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

int gcd(int a, int b) {
    if (b > a) swap(a, b);
    int r = a % b;
    if (r == 0) return b;
    else return gcd(b, r);
}

signed main(void) {
    int N; cin >> N;
    int g;
    rep(i, N) {
        int A; cin >> A;
        if (i > 0) {
            g = gcd(g, A);
        } else {
            g = A;
        }
    }
    cout << g << endl;

    return 0;
}

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line

int main()
{
	int d;
	cin >> d;
	vector<int> c(26);
	rep(i,26) cin >> c[i]; 
	vector<vector<int>> s(d,vector<int>(26));
	rep(i,d) rep(j,26) cin >> s[i][j];

	// 最後に試合を行った日を保持する。
	vector<int> last_d(26,-1);
	ll ans = 0;
	rep(i,d){
		int index = 0;

		int m = 1e9+7;
		int sagaru = 0;
		rep(j,26){
			sagaru += (i - last_d[j]) * c[j];
		}

		rep(j,26){
			int now = sagaru - (i - last_d[j]) * c[j] - s[i][j];
			if(chmin(m,now)){
				index = j;
			}
		}
		int game = index;
		last_d[game] = index;
		ans += s[i][game];
		rep(j,26){
			ans -= c[j] * (i - last_d[j]);
		}
		cout << index+1 << endl;
	}
}


Measured memory_bytes: 3692
#include<stdio.h>
int main(void)
{
	long long int a = 0, b = 0;
	scanf("%lld%lld", &a, &b);

	if (a < b) {
		long long int count1 = a;
		while (1) {
			count1 += a;
			if (count1 % b == 0) {
				break;
			}
		}

		printf("%lld\n", count1);
	}
	else {
	    long long int count2 = 0;
		while (1) {
			count2 += b;

			if (count2 % a == 0) {
				break;
			}
		}

		printf("%lld\n", count2);
	}

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(x) (((long long)x)%modulo)

int H,W;
int cnt = 0;
void check(vector<string> &S,vector<pair<int,int>> &V,int i,int j){
	if(i>=H)return;
	if(i<0)return;
	if(j>=W)return;
	if(j<0)return;
	
	if(S[i][j]=='.'){
		S[i][j]='#';
		V.push_back(make_pair(i,j));
		cnt++;
	}
	
}

int main(){
	
	
	cin>>H>>W;
	
	vector<string> S(H);
	vector<pair<int,int>> V(0);
	
	for(int i=0;i<H;i++){
		cin>>S[i];
		for(int j=0;j<W;j++){
			if(S[i][j]=='#'){
				V.push_back(make_pair(i,j));
				cnt++;
			}
		}
	}
	int ans = 0;
	vector<pair<int,int>> new_V(0);
	while(cnt!=H*W){
		//cout<<V.size()<<endl;
		for(int i=0;i<V.size();i++){
			check(S,new_V,V[i].first+1,V[i].second);
			check(S,new_V,V[i].first-1,V[i].second);
			check(S,new_V,V[i].first,V[i].second-1);
			check(S,new_V,V[i].first,V[i].second+1);
		}
		
		V=new_V;
		new_V.clear();
		ans++;
	}
	
	cout<<ans<<endl;
				
	
	return 0;
}


Measured memory_bytes: 14724
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, L = MAP()
A = LIST()

# 結び目のリストを作っておく
B = []
for i in range(1, N):
    B.append(A[i-1]+A[i])
mx = max(B)
# 一番長いところがL未満なら無理
if mx < L:
    print('Impossible')
    exit()

# 一番長いところに集めてくるように切る
print('Possible')
idx = B.index(mx)
for i in range(idx):
    print(i+1)
for i in range(N-2, idx, -1):
    print(i+1)
print(idx+1)


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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

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

    string s2 = s, t2 = t;
    reverse(s2.begin(), s2.end());
    reverse(t2.begin(), t2.end());

    if (t == s2 && s == t2) {
        puts("YES");
    } else {
        puts("NO");
    }


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    string S;
    cin >> S;
    int A = S[0]-'0', B = S[1]-'0', C = S[2]-'0', D = S[3]-'0';

    for (int i = 0; i < (1 << 3); ++i) {
        int ans = A;
        if (i & (1 << 0)) ans += B;
        else
            ans -= B;

        if (i & (1 << 1)) ans += C;
        else
            ans -= C;

        if (i & (1 << 2)) ans += D;
        else
            ans -= D;

        if(ans==7){
            string X = "";
            X+=to_string(A);
            X+=(i & (1 << 0))?"+":"-";
            X+=to_string(B);
            X+=(i & (1 << 1))?"+":"-";
            X+=to_string(C);
            X+=(i & (1 << 2))?"+":"-";
            X+=to_string(D);
            X+="=7";
            cout << X <<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#from bisect import insort_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
#import heapq
from collections import defaultdict
MOD = pow(10,9)+7
N = int(input())
d = [[N,0] for _ in range(60)]
A = list(map(int,input().split()))
for k in A:
    c = 0
    while k > 0:
        if k % 2 == 1:
            d[c][0] -= 1
            d[c][1] += 1
        k = k // 2
        c += 1
s = 0
for i in range(60):
    li = d[i]
    s += (li[0]*li[1]*pow(2,i,MOD))%MOD
print(s%MOD)

Measured memory_bytes: 123260
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <sstream>
#include <vector>
#include <set>
#include <unordered_map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;
	string s;
	cin >> s;

	auto check = [&](int len) {
	
		unordered_map<string, int> mp;
		for (int j = 0; j <= N - len; j++) {
			string tmp = s.substr(j, len);
			auto itr = mp.find(tmp);
			if (itr == mp.end()) mp.emplace(tmp, j);
			else if (j - itr->second >= len) return true;
		}
		
		return false;
	};

	
	auto biSearch = [&](auto f) {
      int ok = -1;
      int ng = N;

      while (abs(ok - ng) > 1) {
          int mid = (ok + ng);
          mid>>=1;
          if (f(mid)) ok = mid;
          else ng = mid;
      }

      return ok;
	};
	
	cout << biSearch(check) << endl;
	
	return 0;
}


Measured memory_bytes: 6684
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector< vector<int> > VVI;
typedef vector< vector<int> > VVL;
typedef pair<int,int> PII;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair

int main(){
  string S;
  cin>>S;
  int ans=S.size();
  rep(i,S.size()){
    if(i){
      if(S[i-1]!=S[i]) ans=min(ans,max(i,(int)S.size()-i));
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 512
#include<stdio.h>
int main()
{
	int input=0;
	do{scanf("%d",&input);}while(input<1||input>100);
	int ini=1;
	while(ini<input)
	{
		ini*=2;
	}
	if(ini>input)
		printf("%d",ini/2);
	else
		printf("%d",ini);
	return 0;
}

Measured memory_bytes: 128
import Data.List

countEqn :: [Int] -> Int
countEqn xs = (!! last xs) $ foldl' step initDP $ tail lhss
    where lhss = init xs
          initial = head xs
          initDP = (replicate initial 0) ++  [1] ++ (replicate (20 - initial) 0)
          step dp k = let zeros = replicate k 0
                          in zipWith (+) (drop k dp ++ zeros) (zeros ++ dp)

main :: IO ()
main = getLine >> getLine >>= print . countEqn . map read . words

Measured memory_bytes: 4016
#include <iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include<queue>
#include<map>
using namespace std;
long int A[200009];
int main() {
	long long int N;
	cin >> N;
	long long int Y = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		if (i != 0)Y += A[i];
	}

	long long int X = A[0];

	long long int Z = abs(X - Y);
	
	for (int i = 1; i < N-1; i++) {
		X += A[i];
		Y -= A[i];
		if (Z > abs(X - Y))Z = abs(X - Y);
	}

	cout << Z << endl;

	return 0;
}


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

int costs[32];
int N,U,C,K;
int ans;
pair<int, vector<int> > pivv[32];

void dfs(int now, int nowcost, int cnt, int next)
{
	if( ans<cnt )return;
	if( nowcost>=U ){ ans = cnt; return; }
	for(int i=next; i<N; i++){
		if( !(now&(1<<i)) ){
			int j;
			for(j=0; j<pivv[i].second.size(); j++)
				if( !(now&(1<<pivv[i].second[j])) )break;
			if( j==pivv[i].second.size() ){
				dfs(now|(1<<i), nowcost+pivv[i].first, cnt+1, i+1);
			}
		}
	}
	return;
}


int main()
{
	while(cin>>N>>U, N|U){
		pair<int, vector<int> > piv[N];
		//vector<vector<int> > vv(N);
		memset(costs,0,sizeof(costs));
		ans = INT_MAX;
		for(int i=0; i<N; i++){
			cin>>piv[i].first>>K;
			for(int j=0; j<K; j++){
				int a; cin>>a;
				piv[i].second.push_back(a);
			}
		}
		
		// sort
		pair<int, vector<int> > tmp[N],pivtmp[N];
		vector<int> cv;
		int check[N];
		memset(check,0,sizeof(check));
		for(int i=0; i<N; i++)pivtmp[i]=piv[i];
		
		for(int i=0; i<N; i++){
			int pos=-1,tmin=N+1;
			for(int j=0; j<N; j++){
				int k;
				int c = 0;
				int n = pivtmp[j].second.size();
				
				for(k=0; k<n; k++){
					int l;
					for(l=0; l<i; l++)
						if( cv[l]==pivtmp[j].second[k] )break;
					if( l<i || l==0 )c++;
				}
				
				if( c==n && tmin>n && !check[j]){
					pos = j; tmin = n;
				}
			}

			//printf("i:%d , pos:%d\n",i,pos);
			for(int j=0; j<N; j++){
				if( check[j] )continue;
				for(int l=0; l<pivtmp[j].second.size(); l++){
					if( pivtmp[j].second[l]==pos ){
						piv[j].second[l] = i;
						//printf("j:%d\n",j);
					}
				}
			}
			tmp[i] = piv[pos];
			check[pos] = 1;
			cv.push_back(pos);
			
			// __ debug __ 
			/*
			puts("_____debug_____");
			for(int j=0; j<N; j++){
				printf("i:%d, C:%d _ ",i,piv[j].first);
				for(int k=0; k<piv[j].second.size(); k++)
					printf("%d,",piv[j].second[k]);
				puts("");
			}
			puts("_______________");
			*/
		}
		
		/*
		for(int i=0; i<N; i++){
			printf("i:%d, C:%d _ ",i,tmp[i].first);
			for(int j=0; j<tmp[i].second.size(); j++)
				printf("%d,",tmp[i].second[j]);
			puts("");
		}
		*/
		for(int i=0; i<N; i++)pivv[i] = tmp[i];
		dfs(0,0,0,0);
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 916
#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main() 
{
    int n, ans;
    cin >> n >> ans;
    for (int i=0; i<n-1; i++)
    {
        int x;
        cin >> x;
        ans = __gcd(ans,x);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const int iINF = 0x3f3f3f3f;
const long long INF = 1LL << 60;
using namespace std;

template <class T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}

int main()
{
  int H, W, N, sr, sc;
  cin >> H >> W >> N >> sr >> sc;
  --sr;
  --sc;

  string S, T;
  cin >> S >> T;

  bool ok = true;
  int w_min, w_max, h_min, h_max;

  w_min = h_min = 0;
  w_max = W - 1;
  h_max = H - 1;

  if (S[N - 1] == 'L')
    w_min++;
  if (S[N - 1] == 'R')
    w_max--;
  if (S[N - 1] == 'U')
    h_min++;
  if (S[N - 1] == 'D')
    h_max--;

  // 横方向
  for (int i = N - 2; i >= 0; i--)
  {
    if (!ok)
      continue;

    if (T[i] == 'L')
    {
      w_max = min(w_max + 1, W - 1);
    }
    if (T[i] == 'R')
    {
      w_min = max(w_min - 1, 0);
    }

    if (S[i] == 'L')
    {
      w_min++;
    }

    if (S[i] == 'R')
    {
      w_max--;
    }

    if (w_min < 0 || w_max < 0 || w_max < w_min)
      ok = false;

    if (!ok)
    {
      cout << "NO" << endl;
      return 0;
    }
  }
  // 縦方向
  for (int i = N - 2; i >= 0; i--)
  {

    if (!ok)
      continue;

    if (T[i] == 'U')
    {
      h_max = min(h_max + 1, H - 1);
    }
    if (T[i] == 'D')
    {
      h_min = max(h_min - 1, 0);
    }

    if (S[i] == 'U')
    {
      h_min++;
    }
    if (S[i] == 'D')
    {
      h_max--;
    }

    if (h_min < 0 || h_max < 0 || h_max < h_min)
      ok = false;
  }

  if (!ok)
  {
    cout << "NO" << endl;
    return 0;
  }

  // cout << h_min << h_max << w_min << w_max << endl;
  // cout << sr << sc << endl;
  // if スタートが範囲内
  if (h_min <= sr && sr <= h_max && w_min <= sc && sc <= w_max)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 3856
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define co(x) cout << (x) << "\n"
#define pb push_back
#define Never
#define To

using namespace std;

int main(){

	cin.tie(0);
	ios::sync_with_stdio(false);

	long long N, M;

	cin >> N >> M;

	long long A[N];
	long long ans = 0;
	for(long long i = 0; i < N; i++){
		cin >> A[i];
		ans += A[i];
	}

	sort(A, A+N);

	vector<tuple<long long, long long>> t;

	for(long long i = 0; i < M; i++){
		long long b, c;
		cin >> b >> c;
		t.push_back(make_tuple(c, b));
	}

	sort(t.begin(), t.end());

	long long x = 0;
	for(long long i = t.size() - 1; i >=0; i--){
		for(long long j = 0; j < get<1>(t[i]); j++){
			if(A[x] < get<0>(t[i])){
				ans += get<0>(t[i]) - A[x++];
				if(x == N) goto END;
			} else {
				goto END;
			}
		}
	}

END:
	cout << ans << endl;

	Never To return 0;
}


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

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

    // f(n, t) = max(v + f(n-1, t-w), f(n-1, t)) if t-w >= 0
    //           else  f(n-1, t)
    long long dp[N+1][W+1];
    memset(dp, 0, sizeof(dp));

    for (int n = 1, w, v; n <= N; ++n) {
	cin >> w >> v;
	for (int t = 0; t <= W; ++t) {
	    if (t-w >= 0)
		dp[n][t] = max(v + dp[n-1][t-w], dp[n-1][t]);
	    else
		dp[n][t] = dp[n-1][t];
	}
    }
    cout << dp[N][W] << endl;
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;

int main() {
    int n; cin >> n;
    map<string,int> count;
    rep(i,n){
        string s;
        cin >> s;
        count[s]++;
    }
    int m; cin >> m;
    rep(i,m){
        string t;
        cin >> t;
        count[t]--;
    }

    int max_count = 0;
    for (auto & it : count) {
        max_count = max(max_count,it.second);
    }
    print(max_count);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i = (ll)(a); i < (ll)(b); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;
int main(){
    string S; cin >> S;
    int l = S.size();
    rep(i,l){
        cout << 'x';
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
from math import gcd
 
def main():
    k = int(input())
    ans = 0
 
    for i in range(k):
        for j in range(k):
            for ii in range(k):
                ans += gcd(i+1,gcd(j+1,ii+1))
 
    print(ans)
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int inf = 1000000000;

int main() {
    int n, m; cin >> n >> m;
    int e[m][3];
    for (int i = 0; i < m; i++) {
        cin >> e[i][0] >> e[i][1] >> e[i][2];
        e[i][0]--; e[i][1]--;
    }
    int d[n][n];
    for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) {
        if (i == j) d[i][j] = 0;
        else d[i][j] = inf;
    }
    for (int i = 0; i < m; i++) {
        d[e[i][0]][e[i][1]] = e[i][2];
        d[e[i][1]][e[i][0]] = e[i][2];
    }
    for (int k = 0; k < n; k++) for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    }
    int ans = m;
    for (int i = 0; i < m; i++) { //辺iがある頂点間の最短経路に使われるか
        bool found = false;
        for (int j = 0; j < n; j++) {
            for (int k = 0; k < n; k++) {
                if (d[j][k] == d[j][e[i][0]] + e[i][2] + d[e[i][1]][k]) {
                    ans--;
                    found = true;
                    break;
                }
            }
            if (found) break;
        }
    }
    cout << ans << endl;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll x;
  cin >> x;

  ll n1000 = 0, n5 = 0;
  n1000 = x / 500;
  x -= n1000 * 500;
  n5 = x / 5;

  cout << n1000 * 1000 + n5 * 5 << endl;
  return 0;
}


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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  if (a >= 10 || b >= 10) cout << -1 << '\n';
  else cout << a * b << '\n';
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    static int[][] field;
    static int max;

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

	int n = sc.nextInt();
	
	while(n!=0){
	    field = new int[5][5];
	    for(int i=0; i<5; i++){
		for(int j=0; j<5; j++){
		    field[i][j] = sc.nextInt();
		}
	    }
	    max = 0;
	    
	    solve();

	    System.out.println(max);
	    
	    n--;
	}
    }
    
    public static void solve(){
	for(int i=0; i<5; i++){
	    for(int j=0; j<5; j++){
		if(field[i][j]==1){
		    int xLen = getXLength(i,j);
		    int yLen = getYLength(i,j);
		    int len = getRectangle(i,j,xLen,yLen);
		    
		    if(len>max)max = len;
		}
	    }
	}
    }

    public static int getXLength(int i, int j){
	int len = 1;
	//if(j+1>=5){return len;}
	while(j+1<5 && field[i][++j]!=0){len++;}
	//System.out.println(len);
	return len;
    }

    public static int getYLength(int i, int j){
	int len = 1;
	//if(i+1>=5){return len;}
	while(i+1<5 && field[++i][j]!=0){len++;}
	return len;
    }

    public static int getRectangle(int y, int x, int xLen, int yLen){
	int count = 1;
	int maxLen = 0;
	if(xLen>=yLen){maxLen = xLen;}
	else{maxLen = yLen;}
	for(int i=y+1; i<=y+yLen-1; i++){
	    for(int j=x+1; j<=x+xLen-1; j++){
		if(field[i][j]==1){
		    if(maxLen<((i-y+1)*(j-x+1))){
			maxLen = (i-y+1)*(j-x+1);
			//System.out.println((j-x+1)+" "+(i-y+1)+" "+maxLen);
		    }
		}else {xLen=j-x; j=x+xLen-1;}
	    }
	}

	//System.out.println("x:"+x+" y:"+y+" maxLen:"+maxLen);
	return maxLen;
    }
}

Measured memory_bytes: 12000
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a=sc.next();
        String b=sc.next();
        String c=sc.next();
        if(a.charAt(a.length()-1)==b.charAt(0)&&b.charAt(b.length()-1)==c.charAt(0)){
            System.out.println("YES");
            
        }else{
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 23508
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;
int main(){
	double a,b,c,d;
	double PI=3.14159265359;
	while(scanf("%lf%lf%lf%lf",&a,&b,&c,&d),b>-0.5){
		double x=cos(a*PI/180)*sin(b*PI/180)-cos(c*PI/180)*sin(d*PI/180);
		double y=cos(a*PI/180)*cos(b*PI/180)-cos(c*PI/180)*cos(d*PI/180);
		double z=sin(a*PI/180)-sin(c*PI/180);
		printf("%.0f\n",6378.1*2.0*asin(sqrt(x*x+y*y+z*z)/2));
	}
}

Measured memory_bytes: 1132
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
const int INF = (1LL<<30);
const ll LLINF = (1LL<<60);
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;
//#define int ll

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

#define MAX_N 10000
struct edge{ int to, cap, rev; };

vector<edge> G[MAX_N];
int level[MAX_N]; // s??????????????¢
int iter[MAX_N];  // ???????????§??????????????£??????

void add_edge(int from, int to, int cap) {
  G[from].PB({to, cap, (int)G[to].size()});
  G[to].PB({from, 0, (int)G[from].size()-1});
}

void bfs(int s) {
  memset(level, -1, sizeof(level));
  queue<int> que;
  level[s] = 0;
  que.push(s);
  while(que.size()) {
    int v = que.front(); que.pop();
    for(auto i: G[v]) {
      if(i.cap > 0 && level[i.to] < 0) {
        level[i.to] = level[v] + 1;
        que.push(i.to);
      }
    }
  }
}

int dfs(int v, int t, int f) {
  if(v == t) return f;
  for(int &i = iter[v]; i<(int)G[v].size(); ++i) {
    edge &e = G[v][i];
    if(e.cap > 0 && level[v] < level[e.to]) {
      int d = dfs(e.to, t, min(f, e.cap));
      if(d > 0) {
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}

int max_flow(int s, int t) {
  int flow = 0;
  while(1) {
    bfs(s);
    if(level[t] < 0) return flow;
    memset(iter, 0, sizeof(iter));
    int f;
    while((f = dfs(s, t, INF)) > 0) flow += f;
  }
}

signed main(void)
{
  int v, e;
  cin >> v >> e;
  REP(i, e) {
    int p, q, c;
    cin >> p >> q >> c;
    add_edge(p, q, c);
  }

  cout << max_flow(0, v-1) << endl;

  return 0;
}

Measured memory_bytes: 3480
// 解き直し.
// AtCoder Beginner Contest 123 解説.
// https://img.atcoder.jp/abc123/editorial.pdf
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
using LL = long long;
const int MAX = 1e3 + 1;
LL A[MAX], B[MAX], C[MAX];

struct cake{
    LL  d; // 美味しさの合計.
    int a; // A の index.
    int b; // B の index.
    int c; // C の index.
    bool operator < (const cake &C) const { return d < C.d; }
};

// 与えられた情報を結合して, 文字列を返却.
// @param prefix: 接頭語.
// @param d: 美味しさの合計.
// @param a: A の index.
// @param b: B の index.
// @param c: C の index.
// @return ret: map に 登録する 文字列 key.
string makeKey(string prefix, LL d, int a, int b, int c){
    string ret = prefix;
    ret += {"_"};
    ret += to_string(A[a] + B[b] + C[c]);
    ret += {"_"};
    ret += to_string(a);
    ret += {"_"};
    ret += to_string(b);
    ret += {"_"};
    ret += to_string(c);
    return ret;
}

int main(){
    
    // 1. 入力情報取得.
    int X, Y, Z, K;
    scanf("%d %d %d %d", &X, &Y, &Z, &K);
    FOR(i, 0, X) scanf("%lld", A + i);
    FOR(i, 0, Y) scanf("%lld", B + i);
    FOR(i, 0, Z) scanf("%lld", C + i);
    
    // 2. 降順sort.
    sort(A, A + MAX, greater<LL>());
    sort(B, B + MAX, greater<LL>());
    sort(C, C + MAX, greater<LL>());
    
    // 3. 解説通り(※Priority Queue (優先度付きキュー) を 使うパターン).
    int a = 0, b = 0, c = 0;
    priority_queue<cake> pq;
    map<string, int> m;
    pq.push({A[a] + B[b] + C[c], a, b, c});
    string s = makeKey("p", A[a] + B[b] + C[c], a, b, c);
    m[s]++;
    int index = 1;
    while(!pq.empty()){
        // 3-1. pq の中で, 一番美味しさの大きい要素を取得.
        cake i = pq.top();
        a = i.a, b = i.b, c = i.c;
        pq.pop();
        
        // 3-2. 追加されてないパターンを追加.
        cake p1 = {A[a + 1] + B[b] + C[c], a + 1, b, c};
        string s1 = makeKey("p", A[a + 1] + B[b] + C[c], a + 1, b, c);
        cake p2 = {A[a] + B[b + 1] + C[c], a, b + 1, c};
        string s2 = makeKey("p", A[a] + B[b + 1] + C[c], a, b + 1, c);
        cake p3 = {A[a] + B[b] + C[c + 1], a, b, c + 1};
        string s3 = makeKey("p", A[a] + B[b] + C[c + 1], a, b, c + 1);
        if(a < X - 1 && m[s1] == 0) pq.push(p1), m[s1]++;
        if(b < Y - 1 && m[s2] == 0) pq.push(p2), m[s2]++;
        if(c < Z - 1 && m[s3] == 0) pq.push(p3), m[s3]++;

        // 3-3. index番目 のケーキの美味しさの合計を出力.
        printf("%lld\n", i.d);
        
        // 3-4. increment.
        index++;
        
        // 3-5. index番目 が Kより大きくなったら終了.
        if(index > K) break;
    }
    // printf with std::string?
    // https://stackoverflow.com/questions/10865957/printf-with-stdstring
    // for(auto &e : m) printf("key=%s, value=%d\n", e.first.c_str(), e.second);
    return 0;
    
}

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

int N, M, X, A[200];

int main() {
	scanf("%d%d%d", &N, &M, &X);
	for (int i = 0; i < M; ++i) scanf("%d", A + i);

	int l = 0, r = 0;
	for (int i = 0; i < M; ++i) {
		if (X > A[i]) ++l;
		else ++r;
	}
	printf("%d\n", min(r, l));
}


Measured memory_bytes: 256
#include <stdio.h>

#define INF 1000000
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define NIL -1

int n;
int A[128][128];

int prim();

int main(){
        int i, j;

        scanf("%d", &n);

        for(i = 0 ; i < n ; i++){
                for(j = 0 ; j < n ; j++){
                        scanf("%d", &A[i][j]);
                }
        }

        printf("%d\n",prim());
        return 0;
}

int prim(){
        int i, u;
        int d[128], p[128], color[128];
        for(i = 0 ; i < n ; i++){
                d[i] = INF;
                p[i] = NIL;
                color[i] = WHITE;
        }

        d[0] = 0;

        int mincost, v;
        while(1){
                mincost = INF;
                for(i = 0 ; i < n ; i++){
                        if(color[i] != BLACK && d[i] < mincost){
                                mincost = d[i];
                                u = i;
                        }
                }

                if(mincost == INF)break;

                color[u] = BLACK;

                for(v = 0 ; v < n ; v++){
                        if(color[v] != BLACK && A[u][v] != NIL){
                                if(A[u][v] < d[v]){
                                        d[v] = A[u][v];
                                        p[v] = u;
                                        color[v] = GRAY;
                                }
                        }
                }
        }

        int res;
        for(i = res = 0 ; i < n ; i++){
                res += d[i];
        }
        return res;
}



Measured memory_bytes: 2048
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int n;
double dp[305][305][305];//dp[i][j][k]寿司が1個の皿がi枚、2個の皿がj枚、3個の皿がk枚
double rec(int i,int j,int k){
    if(dp[i][j][k]>=-1)return dp[i][j][k];
    double res;
    if(i==0&&j==0&&k==0)res=0;

    else {
        res=0;
        if(i>0)res+=rec(i-1,j,k)*i;
        if(j>0)res+=rec(i+1,j-1,k)*j;
        if(k>0)res+=rec(i,j+1,k-1)*k;
        res+=n;
        res*=1.0/(i+j+k);
    }
    return dp[i][j][k]=res;
}

int main(){
    cin>>n;
    int a,one=0,two=0,three=0;
    rep(i,n){
        cin>>a;
        if(a==1)++one;
        else if(a==2)++two;
        else ++three;
    }
    memset(dp,-1,sizeof(dp));
    printf("%.10lf\n",rec(one,two,three));
    return 0;
}


Measured memory_bytes: 221952
N = int(input())
num = {}
for i in range(N):
    S = input()
    if S in num:
        num[S] += 1
    else:
        num[S] = 1

max = max(num.values())
keys = []
for k, v in num.items():
    if v == max:
        keys.append(k)
keys.sort()

for key in keys:
    print(key)


Measured memory_bytes: 35304
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<iostream>
#include<numeric>
using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int l = a + b, r = c + d;
	if (l > r)
		cout << "Left" << endl;
	else if (l == r)
		cout << "Balanced" << endl;
	else
		cout << "Right" << endl;
}

Measured memory_bytes: 256
MOD = 10**9+7
N, K = map(int, input().split())

s = 0

for i in range(K, N+2):
    s += N*(N+1)//2%MOD - (N-i)*(N+1-i)//2%MOD - (i-1)*i//2%MOD + 1
    s %= MOD

print(s)



Measured memory_bytes: 9184
//
// Created by たかえすみずき on 2017/07/15.
//

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif

//改造
typedef long long int ll;
using namespace std;

int main() {
    vector<int> abc;
    for(int i = 0; i < 3; i++){
        int tmp;
        cin >> tmp;
        abc.push_back(tmp);
    }
    sort(abc.begin(),abc.end(),less<int>());
    int sum = abc[0] + abc[1];
    cout << sum << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repq(i,a,n) for(int i=a; i<=n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

signed main() {
    string s1, s2, s3; cin >> s1 >> s2 >> s3;
    int a = 0, b = 0, c = 0;
    int x = 0;

    map<char, int> m;
    m['a'] = 0;
    m['b'] = 1;
    m['c'] = 2;
    while(1) {
        if(x == 0) {
            if(a == s1.length()) {
                cout << "A" << endl;
                return 0;
            }
            x = m[s1[a++]];
        }
        else if(x == 1) {
            if(b == s2.length()) {
                cout << "B" << endl;
                return 0;
            }
            x = m[s2[b++]];
        }
        else {
            if(c == s3.length()) {
                cout << "C" << endl;
                return 0;
            }
            x = m[s3[c++]];
        }
        // printf("%d %d %d\n", a, b, c);
    }
    return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array.IArray

main :: IO ()
main = do
  (n:k:_) <- fmap (map read . words) getLine :: IO [Int]
  ws <- replicateM n $ readLn :: IO [Int]
  print $ solve k ws

solve :: Int -> [Int] -> Int
solve k ws = lowerBound (isPackable k ws) (m - 1, mx)
  where
    m = maximum ws
    mx = sum ws

-- 条件を満たす最初の要素を指すインデックスを返す
-- lowerBound :: (Ord a, Ix a) => (a -> Bool) -> (a, a) -> a
lowerBound :: (Int -> Bool) -> (Int, Int) -> Int
lowerBound predicate bounds = go bounds
  where
    go (l, h) | l + 1 == h = h
              | predicate m = go (l, m)
              | otherwise = go (m, h)
      where m = (l + h) `div` 2

isPackable :: Int -> [Int] -> Int -> Bool
isPackable k ws p = k >= (snd $ foldl' f (0, 1) ws)
  where
    f :: (Int, Int) -> Int -> (Int, Int)
    f (i, acc) w = if i + w <= p
                   then (i + w, acc)
                   else (w, acc + 1)



Measured memory_bytes: 43648
#include<iostream>
#include<algorithm>
using namespace std;
int main(){

    int n;
    while(cin>>n,n){
        int a[10000];
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        sort(a,a+n);
        long long int ans = 0;
        for(int i=0;i<n-1;i++){
            ans += a[i]*(n-i-1);
        }
        cout<<ans<<endl;


    }
    return 0;
}

Measured memory_bytes: 1208
#include "bits/stdc++.h"
#include "sstream"
#define quick ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
const int N=3e5+1;
vector<int>vc;
int main() {
    quick
int h,n,x,y,mx=0,idx=INT_MAX;
    cin>>n>>h;
while(n--){
    cin>>x>>y; vc.push_back(y);
  if(x>mx)
      mx=x,idx=y;
  else if(x==mx){idx=min(y,idx);}

}
sort(vc.begin(),vc.end(),greater<int>());
int ans=0;
for(int i=0;i<vc.size();i++){
    if(h<=0){break;}
    else if(vc[i]>=mx)
        h-=vc[i],ans++;
    else{break;}
}
if(h<=0){ return cout<<ans,0;}
if(h%mx){ans++;}
cout<<ans+(h/mx);
}

Measured memory_bytes: 892
def main():
    s = raw_input()
    check_b = lambda x: x=='B'
    check_w = lambda x: x=='W'
    if all(map(check_b, list(s))) or all(map(check_w, list(s))):
        return 0

    work = list(s)[:]
    cnt = 0
    for i in range(len(work)-1):
        w_list = work[i:i+2]
        if w_list[0] == w_list[1]:
            pass
        else:
            cnt += 1

    return cnt



if __name__ == '__main__':
    print main()

Measured memory_bytes: 6596
N, M = [int(s) for s in input().rstrip().split()]
pref = [[] for _ in range(N)]
P = []
for m in range(M):
    p, year = [int(s) for s in input().rstrip().split()]
    pref[p-1].append([year, m])
    P.append(p)

id = [None] * M
for n, p in enumerate(pref):
    if not p:
        continue    
    p.sort()
    for x, (year, m) in enumerate(p):
        id[m] = '{0:06d}{1:06d}'.format(n+1, x+1)

print('\n'.join(id))


Measured memory_bytes: 45440
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_B&lang=jp

N = gets.to_i

a = gets.split.map(&:to_i)
cnt = 0
N.times.each do |i|
    minj = i
    (i..N-1).each do |j|
        if a[j] < a[minj]
            minj = j
        end
    end
    if minj != i
        a[i],a[minj] = a[minj],a[i]
        cnt+=1
    end
end

puts a.join(" ")
puts cnt

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

typedef long long lint;

int main(){
    lint N;
    lint x,a[2000];
    lint dp[2000][2001];

    cin >> N >> x;
    lint sum=0;
    for(int i=0;i<N;i++){
        cin >> a[i];
        sum+=a[i];
        dp[0][i]=a[i];
    }
    dp[0][N]=sum;

    for(int mag=1;mag<=N-1;mag++){
        sum=0;
        for(int i=0;i<N;i++){
            dp[mag][i]=(a[i]<dp[mag-1][(i+N-1)%N]?a[i]:dp[mag-1][(i+N-1)%N]);
            sum+=dp[mag][i];
        }
        dp[mag][N]=sum+x*mag;
    }

    lint min=dp[0][N];
    for(int mag=1;mag<=N-1;mag++){
        if(dp[mag][N]<min) min=dp[mag][N];
    }

    cout << min << endl;


    return 0;
}//

Measured memory_bytes: 31616
#include<bits/stdc++.h>
using namespace std;
#define int long
signed main(){
  int n;
  cin>>n;
  vector<int> a(n),b(n);
  for(auto &i:a)cin>>i;
  for(int i=0;i<n%2+n/2;++i)b[i]=a[n-1-i*2];
  for(int i=0;i<n/2;++i)b[i+n/2+n%2]=a[i*2+n%2];
  for(auto i:b)cout<<i<<" ";
}

Measured memory_bytes: 5248
#include<stdio.h>
int main()
{
    int s,h,m;
    while(scanf("%d",&s)!=EOF)
    {
        h=s/3600;
        s=s%3600;
        m=s/60;
        s=s%60;
        printf("%d:%d:%d\n",h,m,s);
    }
    return 0;
}

Measured memory_bytes: 1020
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
	int a,b; cin >> a >> b;
	if(abs(a-b)%2 == 0){
		cout << min(a,b) + abs(a-b)/2 << endl;
	}else{
		cout << "IMPOSSIBLE" << endl;
	}
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main
{
    static int solve(int A[],int B[],int C[])
    {
        int dp[][] = new int[A.length][3];
        dp[0][0]=A[0];
        dp[0][1]=B[0];
        dp[0][2]=C[0];
        for(int i=1;i<A.length;i++)
        {
            dp[i][0]=Math.max(dp[i-1][1],dp[i-1][2])+A[i];
            dp[i][1]=Math.max(dp[i-1][0],dp[i-1][2])+B[i];
            dp[i][2]=Math.max(dp[i-1][0],dp[i-1][1])+C[i];
        }
        return Math.max(Math.max(dp[A.length-1][0],dp[A.length-1][1]),dp[A.length-1][2]);
    }
    public static void main(String []args)throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(System.out));
        int n = Integer.parseInt(br.readLine());
        int A[] = new int[n];
        int B[] = new int[n];
        int C[] = new int[n];
        for(int i=0;i<n;i++)
        {
            int abc[] = Arrays.stream(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
            A[i] = abc[0];
            B[i] = abc[1];
            C[i] = abc[2];
        }
        bw.write(Integer.toString(solve(A,B,C)));
        br.close();
        bw.close();
    }
}


Measured memory_bytes: 57748
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 998244353
#define f(i,n) for(int i=0;i<(int)(n);i++)
#define N 200000


int main() {
	long long a[N];
	f(i, N)a[i] = 0;
	int n, k;
	int x, y, z;
	long long s, ans;
	bool v = true;
	ans = 1;
	scanf("%d", &n);
	f(i, n) {
		scanf("%d", &x);
		a[x]++;
		if ((i == 0) && (x != 0))v = false;
	}
	if (a[0] != 1)v = false;
	f(i, n - 1) {
		f(j, a[i + 2]) {
			ans = (ans*a[i + 1]) % MOD;
		}
	}
	if (v)printf("%lld\n", ans);
	else printf("0\n");


	return 0;
}

Measured memory_bytes: 1664
import java.util.*;
public class Main {

	public static void main(String[] args) {
		int a=0,b=0,ans=0;
		Scanner sc = new Scanner(System.in);
		String c = sc.next();
		a = c.indexOf('A');
		for(int i = a+1;i < c.length();i++) {
			if(c.charAt(i) == 'Z')b = i;
		}
		ans = b - a + 1;
		System.out.println(ans);
	}

}


Measured memory_bytes: 24776
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n,k=LI()

  l=[]
  for _ in range(n):
    l.append(I())

  l.sort()

  mn=l[-1]-l[0]
  for i in range(n-k+1):
    mn=min(mn,l[i+k-1]-l[i])

  return mn

print(main())


Measured memory_bytes: 9956
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    char s[1000];
    int i=0;
    cin>>s;
    while(i<strlen(s)/2)
    {
        if(s[i]!=s[strlen(s)-i-1])
        {
            cout<<"No";
            return 0;
        }
        i++;
    }
    cout<<"Yes";
    return 0;
}


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

lli n;

lli a[1005];
void dfs(lli d, lli b)
{
    if (d == n) {
        if (!(b & 1))
            ans++;
        return;
    }
    rep(i, 3)
    {
        dfs(d + 1, b * (a[d] + i - 1) % 2);
    }
}
int main()
{
    cin >> n;
    rep(i, n) cin >> a[i];
    dfs(0, 1);
    cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))

a = [0 for i in range(n)]

for i in range(n-1):
  if h[i] < h[i+1]: 
    a[i+1] = 0
  else:
    a[i+1] = a[i] + 1
    
print(max(a))

Measured memory_bytes: 14252
// Aizu Vol-2 0216: Cutting Down Water Bills
// 2017.8.6

#include <stdio.h>

int main()
{
	int w, s;

	while (1) {
		scanf("%d", &w);
		if (w < 0) break;
		s = 1150;
		if (w > 10)	s += (w <= 20) ? (w - 10) * 125 : 1250;
		if (w > 20)	s += (w <= 30) ? (w - 20) * 140 : 1400;
		if (w > 30) s += (w - 30) * 160;
		printf("%d\n", 4280 - s);
	}
	return 0;
}

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

#define  PI 3.14159265358979

int main( void ) {

    vector<int> a, b;
    vector<char> op;
    int          cnt = 0;
    while(1){
        int ta, tb;
        char top;
        cin >> ta >> top >> tb;
        if( top == '?' ) break;
        a.push_back( ta );
        b.push_back( tb );
        op.push_back( top );
        cnt++;
    }
    for( int i = 0; i < cnt; i++){
        switch(op.at(i)){
            case '+':
                cout << a.at( i ) + b.at( i ) << endl;
                break;
            case '-':
                cout << a.at( i ) - b.at( i ) << endl;
                break;
            case '*':
                cout << a.at( i ) * b.at( i ) << endl;
                break;
            case '/':
                cout << a.at( i ) / b.at( i ) << endl;
                break;
        }
    } return 0;
}



Measured memory_bytes: 3164
while True:
    line = input()
    if "?" in line:
        break
    lst = line.split()
    #print(lst)
    if lst[1] == "+":
        print(int(lst[0])+int(lst[2]))
    elif lst[1] == "-":
        print(int(lst[0])-int(lst[2]))
    elif lst[1] == "*":
        print(int(lst[0])*int(lst[2]))
    elif lst[1] == "/":
        print(int(lst[0])//int(lst[2]))


Measured memory_bytes: 5600