akhauriyash/Code-Regression huggingface dataset:
#define DEBUG 0

/**
 * File    : D.cpp
 * Author  : Kazune Takahashi
 * Created : 3/9/2019, 9:11:28 PM
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(10101010));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

ll A, B;

ll X(ll L)
{
  L++;
  ll ans = 0;
  if (L % 4 == 2 || L % 4 == 3)
  {
    ans++;
  }
  for (auto i = 1; i < 60; i++)
  {
    ll M = (1LL << (i + 1));
    ll cnt = L % M;
#if DEBUG == 1
    cerr << "M = " << M << ", cnt = " << cnt << endl;
#endif
    if (cnt >= M / 2)
    {
      cnt -= M / 2;
      if (cnt % 2 == 1)
      {
        ans += (1LL << i);
      }
    }
#if DEBUG == 1
    cerr << "ans = " << ans << endl;
#endif
  }
  return ans;
}

int main()
{
  cin >> A >> B;
  if (A == 0)
  {
    cout << X(B) << endl;
  }
  else
  {
    cout << (X(A - 1) ^ X(B)) << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>
#include <chrono>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e18;
    // const int mod = 2600000069;
    // const int p = 10;
    // const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e18;
    // const int mod = 2600000069;
    // const int p = 179;
    // const ld PI = 3.1415926535;
#endif

// #pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,sse3,sse4")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC optimize("fast-math")
// #pragma GCC target("avx2")
//#pragma GCC optimize("section-anchors")
//#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
//#pragma GCC optimize("vpt")
//#pragma GCC optimize("rename-registers")
//#pragma GCC optimize("move-loop-invariants")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC optimize("function-sections")
//#pragma GCC optimize("data-sections")`  

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> b(n);
    for (int i = 0; i < n; i++) cin >> b[i];
    vector<vector<int>> g(n);
    int u, v;
    for (int i = 0; i < m; i++) {
        cin >> u >> v;
        u--, v--;
        g[u].pb(v);
        g[v].pb(u);
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        bool ok = 1;
        for (auto k : g[i]) {
            if (b[k] >= b[i]) {
                ok = 0;
                break;
            }
        }
        ans += ok;
    }
    cout << ans;
}
/*

*/  


Measured memory_bytes: 9800
#include <iostream>
#include <vector>

using namespace std;

int N;

vector<int> A_ary;

int main()
{
	cin >> N;
	A_ary = vector<int>(N);
	for (int i=0; i < N; i++) {
		cin >> A_ary.at(i);
	}

	int f_index=0;
	int f_num = A_ary.at(0);

	int s_num = -1;

	for (int i = 1; i < N; i++) {

		if (A_ary.at(i) > f_num) {
			s_num = f_num;

			f_num = A_ary.at(i);
			f_index = i;

		}
		else if (A_ary.at(i) > s_num) {
			s_num = A_ary.at(i);

		}
	}

	for (int i = 0; i < N; i++) {
		if (i != f_index) {
			cout << f_num << endl;
		}
		else {
			cout << s_num << endl;
		}

	}

	return 0;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
#include <cstdio>
using namespace std;
#define ll  long long
#define PB push_back
#define ld long double
#define ff first
#define ss second
# define st(v) (v).begin(),(v).end()
#define   pr pair<int,int>
const int dx[4] = {1,0,0,-1};
const int dy[4] = {0,-1,1,0};
void solve(){
	int n ;
	cin >> n ;
	vector < int > a(n) ;
	int ans = INT_MAX ;
	for( int i = 0 ; i < n ; i++) cin>> a[i] ;
	for( int T = 1 ; T < n ; T++){
		int s1 = 0, s2 = 0;
		for( int i = 0 ; i < n ; i++){
			if(i>=T)
				s1+=a[i];
			else
				s2+=a[i];
		}
		//cout << abs(s1-s2) << " " ;
		ans = min(ans,abs(s1-s2));
	}
	cout << ans ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int q=1;
    //cin >> q;
    while(q--)
        solve();
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		final long MOD = 1000000007;
		
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] l = new int[M];
		int[] r = new int[M];
		int[] x = new int[M];
		for(int i=0; i<M; i++) {
			l[i] = sc.nextInt()-1;
			r[i] = sc.nextInt();
			x[i] = sc.nextInt();
		}
		
		long[][][] dp = new long[2][N+1][N+1];
		dp[0][0][0] = 1;

		for(int i=0; i<N; i++) {
			for(int j=0; j<N+1; j++)
				Arrays.fill(dp[(i+1)%2][j], 0);
			int[] lenmin = new int[3];
			int[] lenmax = new int[3];
			Arrays.fill(lenmax, 10000);
			for(int j=0; j<M; j++) {
				if(l[j]<=i && i+1==r[j]) {
					if(x[j]<3)
						lenmin[x[j]] = Math.max(lenmin[x[j]], i+1-l[j]);
					if(x[j]>1)
						lenmax[x[j]-1] = Math.min(lenmax[x[j]-1], i+1-l[j]);
				}
			}
			
			for(int j=0; j<=i; j++) {
				for(int k=j==i ? j : j+1; k<=i; k++) {
					if(lenmin[1]<=j+1 && j+1<lenmax[1] && lenmin[2]<=k+1 && k+1<lenmax[2])
						dp[(i+1)%2][j+1][k+1] = (dp[(i+1)%2][j+1][k+1] + dp[i%2][j][k])%MOD;
					if(0<i && lenmin[1]<=1 && 1<lenmax[1] && lenmin[2]<=k+1 && k+1<lenmax[2])
						dp[(i+1)%2][1][k+1] = (dp[(i+1)%2][1][k+1] + dp[i%2][j][k])%MOD;
					if(j<i && lenmin[1]<=1 && 1<lenmax[1] && lenmin[2]<=j+1 && j+1<lenmax[2])
						dp[(i+1)%2][1][j+1] = (dp[(i+1)%2][1][j+1] + dp[i%2][j][k])%MOD;
				}
			}
		}
		
		long ans = 0;
		for(int i=0; i<=N; i++) {
			for(int j=i+1; j<=N; j++) {
				ans = (ans + dp[N%2][i][j]*6)%MOD;
			}
		}
		ans = (ans + dp[N%2][N][N]*3)%MOD;
		System.out.println(ans);
		sc.close();
	}
}


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

void solve(int n) {
	int cnt = 0;
	for (int i = 0; i <= 1000; i++) {
		for (int j = 0; j <= 1000; j++) {
			if (n - i - j >= 0) {
				if (n - i - j <= 1000) {
					cnt += n - i - j + 1;
				} else if (n - i - j <= 2000) {
					cnt += 2000 - (n - i - j) + 1;
				}
			}
		}
	}
	cout << cnt << endl;
}

int main() {
	int n;
	while (cin >> n) {
		solve(n);
	}
}
	

Measured memory_bytes: 3108
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
using namespace std;
int main(){
  int n;
  cin >> n;
  double ans = 0;
  for(int i = 0; i < n; i++){
      double num;
      string s;
      cin >> num >> s;
      if(s == "BTC") ans = ans + num*380000;
      else ans = ans + num;
  }
  cout << ans << endl;
}
  


Measured memory_bytes: 256
//実装が重そうな問題はある程度考えてから書く
//初期化を忘れずに（特に二分探索とか）
//コーナーケースを考えて（特に場合分けとか）
#include <bits/stdc++.h>
#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define int LL
#define zero 0LL
using namespace std;
template<typename T> inline void maximize(T &a,T b){a=max(a,b);}
template<typename T> inline void minimize(T &a,T b){a=min(a,b);}
template<typename T> inline bool middle(T a,T b,T c){return b<=a && a<=c;}
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
inline void outputVI(VI x){REP(i,SI(x)){cout << three(i," ","") << x[i];}OUT("");}
const int SIZE1=1e6+1000;
const int SIZE2=2010;
const int SIZE3=400;
const int SIZE=SIZE1;
const LL p=7+1e9;
const LL INF=1LL<<60;
const long double EPS=1e-7;
string s;
ut N,M,K,X,L,Y,D;
bool able(int f,int c){
	return c>=f*(1+f);
}
int solve(int c,int a,int b){
	if(a>b) return 0;
	int s=a,e=b;
	while(s<=e){
		int f=(s+e)/2;
		if(able(f,c))
			s=f+1;
		else
			e=f-1;
	}
	return e-a+1;
}
signed main(){
	int Q;
	cin >> Q;
	int a,b;
	REP(i,Q){
		cin >> a >> b;
		if(a>b) swap(a,b);
		if(a>=b-1){
			cout << (a-1)*2 << endl;
			continue;
		}
		int ans=0;
		ans+=(a-1)*2;
		int ca=solve(a*b-1,a+1,b-1);
		ans+=ca*2+1;
		ca=a+1+ca;
		//cout << ca << endl;
		if(ca*ca< a*b) ans++;
		cout << ans << endl;
	}
	return 0;
}

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

int main() {
  int K, X;
  cin >> K >> X;

  for (int i = -1000000; i < 1000000; i++) {
    if (X - (K-1) <= i && X + (K - 1) >= i) {
      cout << i << " ";
    }
  }
  cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long q,s,d,n,h,ans;
int main()
{
	cin>>q>>h>>s>>d>>n;
	if(n%2==0)
		ans=min(n/2*d,n*min(s,min(2*h,4*q)));
	else
		ans=min(n/2*d,(n-1)*min(s,min(2*h,4*q)))+min(s,min(2*h,4*q));
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include "iostream"
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <math.h>
#include <numeric>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
using namespace std;
using ll=long long;
#define mod  1000000007

ll gcd(ll a, ll b){
        if(b == 0) return a;
        return gcd(b, a % b);
}
// 最小公倍数を求める関数
ll lcm(ll a, ll b){
        return a / gcd(a, b) * b;
}



int main(int argc, char const *argv[]) {
  ll ans, n;
  std::cin >> n >> ans;

  for(int i=0; i<n-1; i++){
    ll t;
    std::cin >> t;
    ans= lcm(ans,t);
  }

  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;
int a[100];
ll po(ll n, int a) {
	ll res = 1;
	rep(i,a) res *= n;
	return res;
}
int main() {
	int n, p;
	int even = 0, odd = 0;
	cin >> n >> p;
	rep(i,n) {
		cin >> a[i];
		if (a[i]%2 == 0) even++;
		else odd++;
	}
	
	if (even == n) {
		if (p == 0) cout << po(2,n) << endl;
		else cout << 0 << endl;
	} else {
		cout << po(2,n-1) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <bitset>

long long mod = 1e9+7;
class Mint {
public:
  long long x;
  Mint(){}; // 引数なしでも定義できるように引数なしコンストラクタも用意しておく
  Mint(long long a){
    x = a%mod;
    while(x<0){
      x += mod;
    }
  };
  Mint& operator += (const Mint &a){
    x+=a.x;
    x%=mod;
    return *this;
  }
  Mint& operator -= (const Mint &a){
    x += (mod - a.x);
    x%=mod;
    return *this;
  }
  Mint& operator *= (const Mint &a){
    x*=a.x;
    x%=mod;
    return *this;
  }

  // a^n mod を計算する
  // Useaeg: Mint z = Mint(2).pow(n);
  Mint pow(long long n) const {
    if (n==0) return Mint(1);
    Mint y = pow(n>>1); // pow(n/2)を計算する
    y *= y;
    if (n%2==1) y *= *this;
    return y;
  }

  // a^{-1} mod を計算する
  Mint modinv(const Mint &a) const {
    return a.pow(mod-2);
  }

  Mint& operator /= (const Mint &a) {
    x *= modinv(a).x;
    x %= mod;
    return *this;
  }

  Mint operator + (Mint &a) const {
    Mint y(*this);
    y += a;
    return y;
  }

  Mint operator - (Mint &a) const {
    Mint y(*this);
    y -= a;
    return y;
  }

  Mint operator * (Mint &a) const {
    Mint y(*this);
    y *= a;
    return y;
  }

  Mint operator / (Mint &a) const {
    Mint y(*this);
    y/=a;
    return y.x;
  }

  // nCk @mod を計算する
  Mint nCk(Mint &n, const long long k) const {
    Mint y = Mint(1);
    Mint one = Mint(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
      y /= (i + one);
    }
    return y;
  }

  // nPk @mod を計算する
  Mint nPk(Mint &n, long long k) const {
    Mint y(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
    }
    return y;
  }
};

int main() {
  int N;
  std::cin >> N;
  std::vector<long long > A(N);
  for (int i=0; i<N; i++) {
    std::cin >> A[i];
  }
  Mint sum(0);
  Mint sum2(0);
  for (int i=0; i<N; i++) {
    sum += Mint(A[i]);
    Mint tmp(A[i]);
    tmp *= Mint(A[i]);
    sum2 += tmp;
  }
  Mint ans(sum.x);
  ans *= sum;
  ans -= sum2;
  ans /= 2;
  std::cout << ans.x << std::endl;
  return 0;
}


Measured memory_bytes: 4368
n = int(input())
d, x = map(int, input().split())
a = list(int(input()) for i in range(n))
ans = 0

for i in range(n):
    t = a[i]
    for j in range(100):
        if t*j+1 <= d:
            ans += 1
        
print(ans+x)

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

int main() {
    int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
    int xd = abs(tx-sx);
    int yd = abs(ty-sy);
    rep(i, xd){
        cout << "R";
    }
    rep(i, yd){
        cout << "U";
    }
    rep(i, xd){
        cout << "L";
    }
    rep(i, yd){
        cout << "D";
    }
    cout << "D";
    rep(i, xd+1){
        cout << "R";
    }
    rep(i, yd+1){
        cout << "U";
    }
    cout << "L";
    cout << "U";
    rep(i, xd+1){
        cout << "L";
    }
    rep(i, yd+1){
        cout << "D";
    }
    cout << "R" << endl;

    return 0;
}

Measured memory_bytes: 3580
import math
#n=input()
a,b,h,m=map(int,input().split())
#a=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
pi=math.pi
h=h*60+m
x=max(2*pi*h/(12*60),2*pi*m/60)-min(2*pi*h/(12*60),2*pi*m/60)

print((a**2+b**2-2*a*b*math.cos(x))**(1/2))


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

namespace ABC161
{
  class Program
  {
    const char kWhiteSpace = ' ';

    static void Main(string[] args)
    {
      var ABC = Console.ReadLine().Split(kWhiteSpace);
      Swap(ABC, 0, 1);
      Swap(ABC, 0, 2);
      
      Console.WriteLine($"{ABC[0]} {ABC[1]} {ABC[2]}");
    }

    static void Swap(string[] arr, int i, int j)
    {
      var temp = arr[j];
      arr[j] = arr[i];
      arr[i] = temp;
    }
  }
}


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

using namespace std;

int main()
{
	char s[200];
	char p[101];
	int i, j;

	i = 0;
	j = 0;

	while (1) {
		scanf("%c", &s[i]);
		if (s[i] == '\n') break;
		i++;
	}
	for (int k = 0; k < i; k++)
		s[k + i] = s[k];


	while (1) {
		scanf("%c", &p[j]);
		if (p[j] == '\n') break;
		j++;
	}
	int m;
	for (int k = 0; k < i; k++) {
		if (s[k] == p[0]) {
			for (m = 0; m < j; m++) {
				if (s[k + m] != p[m])
					break;
			}
			if(m == j) {
				printf("Yes\n");
				return (0);
			}
		}
	}
	printf("No\n");

	return (0);
}

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

int main()
{
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  int Left = A + B;
  int Right = C + D;

  if (Left > Right) cout << "Left" << endl;
  else if (Right > Left) cout << "Right" << endl;
  else cout << "Balanced" << endl;

  return 0;
}

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

int main()
{
  using namespace std;

  int i, n;
  vector<int> a, b, c;
  int score = 0;

  cin >> n;

  for (i = 0; i < n; i++) {
    int a1;
    cin >> a1;
    a.push_back(a1);
  }

  for (i = 0; i < n; i++) {
    int b1;
    cin >> b1;
    b.push_back(b1);
  }

  for (i = 0; i < n-1; i++) {
    int c1;
    cin >> c1;
    c.push_back(c1);
  }

  for (i = 0; i < n; i++) {
    score += b[a[i]-1];
  }

  for (i = 0; i < n-1; i++) {
    if (a[i+1] - a[i] == 1) {
      score += c[a[i]-1];
    }
  }

  cout << score << endl;

  return 0;
}


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



int main(void){
int n;
int sum=0;
int low=99999999;
int a[105];
scanf("%d",&n);

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

for(int j=-100;j<=100;j++){
    sum=0;
    for(int k=0;k<n;k++){
        sum=sum+(a[k]-j)*(a[k]-j);
    }
    if(sum<=low){low=sum;}
}
printf("%d\n",low);
}


Measured memory_bytes: 128
N, M = map(int, input().split())
if N >= 2 and M >= 2:
    print(N * M - (N - 2) * 2 - 2 * M)
else:
    if N == 1 and M == 1:
        print(1)
    elif N == 1:
        print(M - 2)
    else:
        print(N - 2)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T> >;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (b)-1; i >= (a); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
const ld EPS = 1e-12L;
const ld PI = 3.1415926535897932385L;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ull x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class S, class T>inline bool chmax(S &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class S, class T>inline bool chmin(S &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    ll m = 1;
    ll c = 1;
    while(m <= n){
        if(m == n){
            cout << "Yes" << endl;
            ll now = 1;
            vvll s(c+1, vll());
            rep(i, c)repr(j, i+1, c+1){
                s[i].emplace_back(now);
                s[j].emplace_back(now);
                now++;
            }
            cout << c+1 << "\n";
            rep(i, c+1){
                cout << c << " ";
                rep(j, c){
                    cout << s[i][j] << " \n"[j==c-1];
                }
            }
            return 0;
        }else{
            c++;
            m += c;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3200
# coding: utf-8
def maxHeapify(A, i):
    l = 2*i
    r = 2*i+1
    
    if l <= H and A[l] > A[i]:
        largest = l
    else:
        largest = i
        
    if r <= H and A[r] > A[largest]:
        largest = r
    if largest != i:
        A[i],A[largest] = A[largest],A[i]
        maxHeapify(A, largest)
        
def buildMaxHeap(A):
    for i in range(H/2,0,-1):
        maxHeapify(A,i)

H = int(raw_input())
A = map(int, [0]+raw_input().split())
buildMaxHeap(A)
print " " + " ".join(map(str,A[1:]))

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

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

  string s, t;
  cin >> s >> t;
  int ans = 0;
  rep(i, 0, 3) if (s[i] == t[i]) ans++;
  cout << ans << endl;
}


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

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int a, b;
	char op;
	cin >> a >> op >> b;
	if (op == '+') cout << a+b;
	else cout << a-b;
}

Measured memory_bytes: 256
n =int(input())
a = [int(i) for i in input().split()]
a= sorted(a,reverse =True)
summ = a[0]
n-=2
i = 1
while(n>=2):
    summ+=2*a[i]
    i+=1
    n-=2
if n==1:
    summ+=a[i]
print(summ)

Measured memory_bytes: 31448
from sys import stdin


def main():
    X = int(stdin.readline().rstrip())
    result = 1
    for b in range(1, X + 1):
        for p in range(2, X):
            if b ** p <= X:
                result = max(result, b ** p)
            else:
                break
        if b ** 2 > X:
            continue
    print(result)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  cout << "ABC" << n << endl;
  return 0;
}

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

class Heap {
    vector<int> v;
    void maxHeapify(int i){
        int left,right,largest;
        left = 2 * (i + 1) - 1;
        right = 2 * (i + 1);
        largest = i;
        if (left < v.size() && v[left] > v[largest]){
            largest = left;
        }
        if (right < v.size() && v[right] > v[largest]){
            largest = right;
        }

        if (largest != i){
            swap(v[i],v[largest]);
            maxHeapify(largest);
        }
    }

public:
    Heap(const vector<int> &heap) : v(heap) {
        for (int i = (v.size() - 1) / 2; i >= 0; --i) maxHeapify(i);
    }

    void print(){
        for (auto item : v) cout << " "  << item;
        cout << endl;
    }

};


int main(){
//    freopen("in", "r", stdin);

    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    Heap heap(v);
    heap.print();
    return 0;
}

Measured memory_bytes: 6664
#include <iostream>
#include <cstdio>
#include <cmath>
#include <climits>
using namespace std;
typedef pair<double, int> P;

int main(void) {
    int kosu, year;
    while(cin >> kosu, kosu != 0){
        cin >> year;
        P max = P((double)INT_MIN, 0);
        for(int r = 0; r < kosu; r++) {
            double number, nennri, kind; cin >> number >> nennri >> kind;
            double motoriMultiple;
            if(kind == 1) {motoriMultiple = (1 + (year * nennri / 100.0));}
            else if(kind == 2) {motoriMultiple = pow((1 + nennri / 100.0), year);}
            if(motoriMultiple > max.first) {
                max = P(motoriMultiple, (int)number);
            }
        }
        cout << max.second << endl;
    }
    return(0);
}

Measured memory_bytes: 1232
import java.util.*;
import java.io.*;

class Main{
  public static int mod(int a, int b){
  	return a>b?a-b:b-a;
  }
  public static void main(String args[]){
    Scanner sc=new Scanner(System.in); 
	int n=sc.nextInt();
    int[] arr=new int[n];
    int[] cost=new int[n];
    
    for(int i=0;i<n;i++){
        	arr[i]=sc.nextInt();
    }
    cost[0]=0;
    cost[1]=mod(arr[0],arr[1]);
    for(int i=2;i<n;i++){
    	cost[i]=Math.min(cost[i-1]+mod(arr[i-1],arr[i]),cost[i-2]+mod(arr[i-2],arr[i]));
    }
    System.out.println(cost[n-1]);
  }
       }

Measured memory_bytes: 58864
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		List<Long> bars = new ArrayList<>();
		long h = 0;
		long w = 0;

		for (int i = 0; i < n; i++) {
			long x = Integer.parseInt(sc.next());
			bars.add(x);
		}

		Map<Object, Long> result = bars.stream().collect(
				Collectors.groupingBy(x -> x, Collectors.counting()));

		Object[] uniqueBars = bars.stream()
		.distinct().sorted(Comparator.reverseOrder()).toArray();

		for (Object x : uniqueBars) {
			if (result.get(x) >= 4 && (h == 0 && w == 0)) {
				h = (long) x;
				w = (long) x;
				break;
			}
			else if (result.get(x) >= 2 && h == 0) {
				h = (long) x;
				continue;
			} else if (result.get(x) >= 2 && w == 0) {
				w = (long) x;
				continue;
			}
		}

		System.out.println(h * w);
	}
}


Measured memory_bytes: 57492
#include<stdio.h>

int x[100001]={};
int diff[100001]={};
  
void q_sort(int numbers[], int left, int right)
{
  int pivot, l_hold, r_hold;

  l_hold = left;
  r_hold = right;
  pivot = numbers[left];
  while (left < right)
    {
      while ((numbers[right] >= pivot) && (left < right))
	right--;
      if (left != right)
	{
	  numbers[left] = numbers[right];
	  left++;
	}
      while ((numbers[left] <= pivot) && (left < right))
	left++;
      if (left != right)
	{
	  numbers[right] = numbers[left];
	  right--;
	}
    }
  numbers[left] = pivot;
  pivot = left;
  left = l_hold;
  right = r_hold;
  if (left < pivot)
    q_sort(numbers, left, pivot-1);
  if (right > pivot)
    q_sort(numbers, pivot+1, right);
}


int main()
{
  int n,m;
  int i;
  int ans = 0;
  
  scanf("%d %d", &n, &m);

  for (i = 0; i < m; i++) {
    scanf("%d", &x[i]);
  }

  q_sort(x, 0, m - 1);

  for (i = 0; i < m - 1; i++) {
    diff[i] = x[i + 1] - x[i];
  }

  q_sort(diff, 0, m - 2);

  for (i = 0; i < m - n; i++) {
    ans += diff[i];
  }

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


Measured memory_bytes: 1408
#define _GIBCXX_DEBUG
#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 namespace std;
using ll = long long;
using P = pair<int, int>;


int main(void) {
  ll a, b, k;
  cin >> a >> b >> k;

  set<ll> st;

  for (int i = a; i < a + k; ++i) {
    if (i <= b) {
      st.insert(i);
    }
  }
  for (int i = b - k + 1; i <= b; ++i) {
    if (i >= a) {
      st.insert(i);
    }
  }

  for (auto itr = st.begin(); itr != st.end(); ++itr) {
    cout << *itr << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define INF 1e+9
typedef long long ll;
void chmin(ll &a, ll b) { if (a > b) a = b; }
    ll n,A,B,C;
    vector<ll> l;
    
ll dfs(int cnt,ll a,ll b, ll c){
    if(n==cnt){
        if(!a||!b||!c)return INF;
        return abs(a-A)+abs(b-B)+abs(c-C);
    }
    ll res = dfs(cnt+1,a,b,c);
    //ll ret1 = dfs(cnt+1,a+l[cnt],b,c)+a?10:0;
    //ll ret2 = dfs(cnt+1,a,b+l[cnt],c)+b?10:0;
    //ll ret3 = dfs(cnt+1,a,b,c+l[cnt])+c?10:0;
    chmin(res, dfs(cnt+1, a + l[cnt], b, c) + (a ? 10 : 0));
    chmin(res, dfs(cnt+1, a, b + l[cnt], c) + (b ? 10 : 0));
    chmin(res, dfs(cnt+1, a, b, c + l[cnt]) + (c ? 10 : 0));
    
    return res;
}

int main(){
    cin>>n>>A>>B>>C;
    l.resize(n);
    for(int i=0;i<n;i++){
        cin>>l[i];
    }
    cout<<dfs(0,0,0,0)<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define x             first
#define y             second
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define PI            3.14159265358979
#define N             200005

int solve(){
    string s,t; cin>>s>>t;
    int ans=0;
    for(int i=0; i<sz(s); i++){
        if(s[i]!=t[i])
            ans++;
    }
    cout<<ans;
    return 0;
}

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0;
}

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

public static class Program
{
    public static void Main(string[] args)
    {
        var s = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var n = s[0];
        var m = s[1];
        int[][] l = new int[m][];
        for (int i = 0; i < m; i++)
        {
            l[i] = new int[4];
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            l[i][0] = i;
            l[i][1] = a[0];
            l[i][2] = a[1];
        }
        Array.Sort(l, (a, b) => a[2] - b[2]);
        var c = new int[n];
        for (int i = 0; i < m; i++)
        {
            c[l[i][1] - 1]++;
            l[i][3] = c[l[i][1] - 1];
        }
        Array.Sort(l, (a, b) => a[0] - b[0]);
        for (int i = 0; i < m; i++)
        {
            Console.WriteLine(string.Format("{0:D6}", l[i][1]) + string.Format("{0:D6}", l[i][3]));
        }
    }
}

Measured memory_bytes: 26492
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <numeric>
#include <bitset>
#include <ext/algorithm>
#include <ext/numeric>
#define ffor(_a,_f,_t) for(int _a=(_f),__t=(_t);_a<__t;_a++)
#define all(_v) (_v).begin() , (_v).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back
#define SET(__set, val) memset(__set, val, sizeof(__set))
#define FOR(__i, __n) ffor (__i, 0, __n)
typedef long long LL; using namespace std;

const LL MOD = 998244353LL;

LL powmy(LL a, LL p) {
	if (!p)
		return 1LL;
	LL ret = powmy(a, p >> 1);
	ret *= ret;
	ret %= MOD;
	if (p & 1) {
		ret *= a;
		ret %= MOD;
	}
	return ret;
}

LL invmy(int n) {
	return powmy(n, MOD - 2);
}

vector<int> divisors[1 << 20];
vector<LL> prod;
vector<LL> sum;
LL inv[1 << 20];
LL val[1 << 20];

int main() {
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
	
	FOR (i, 1 << 20)
		divisors[i].clear();
	
	ffor (d, 1, 1 << 20) {
		int val = d;
		while (val < 1 << 20) {
			divisors[val].eb(d);
			val += d;
		}
	}
	
	ffor (i, 1, 1 << 20)
		inv[i] = invmy(i);
	
	prod.resize(1 << 20, 0LL);
	sum.resize(1 << 20, 0LL);
	int n;
	cin >> n;
	LL x;
	vector<int> A;
	FOR (i, n) {
		cin >> x;
		A.eb(x);
		for (auto &div : divisors[x]) {
			prod[div] += sum[div] * x;
			sum[div] += x;
			sum[div] %= MOD;
			prod[div] %= MOD;
		}
	}
	
	LL ret = 0LL;
	ffor (i, 1, 1 << 20) {
		val[i] = inv[i];
		for (auto &div : divisors[i]) {
			if (div == i)
				break;
			val[i] -= val[div];
		}
		val[i] %= MOD;
		if (val[i] < 0)
			val[i] += MOD;
		ret += val[i] * prod[i];
		ret %= MOD;
	}
	
	if (ret < 0)
		ret += MOD;
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 154232
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    int ans = 0;
    char temp = '9';
    for(int i = 0; i < n; i++) {
      char c = s.charAt(i);
      if(temp != c) {
        ans++;
        temp = c;
      }
    }
    System.out.println(ans);
  }
}


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

char str[43][43]; long long ans , dp[43][43][43] , N;

long long dfs(int l , int mid , int r){
	if(l == r) return 1;
	if(l == mid || r == mid) return 0;
	if(dp[l][mid][r] != -1) return dp[l][mid][r];
	dp[l][mid][r] = 0;
	for(int j = l ; j < mid ; ++j)
		for(int k = mid + 1 ; k <= r ; ++k)
			if(str[j][k] == '1')
				for(int p = j ; p < mid ; ++p)
					for(int q = mid + 1 ; q <= k ; ++q)
						dp[l][mid][r] += dfs(l , j , p) * dfs(p + 1 , mid , q - 1) * dfs(q , k , r);
	return dp[l][mid][r];
}

int main(){
	memset(dp , -1 , sizeof(dp));
	scanf("%lld" , &N); for(int i = 1 ; i <= 2 * N ; ++i) scanf("%s" , str[i] + 1);
	for(int i = 2 ; i <= 2 * N ; ++i) if(str[1][i] == '1') ans += dfs(2 , i ,  2 * N);
	cout << ans; return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;

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

  int n; cin >> n;
  ll ans = 0;
  if(n >= 500) {
    ans += (n / 500) * 1000;
    n = n % 500;
  }
  if(n >= 5) {
    ans += (n / 5) * 5;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int q;
  cin >> q;
  vector<set<int>> count(26);
  rep(i, n) {
    count[s[i] - 'a'].insert(i);
  }
  rep(qi, q){
    int type;
    cin >> type;
    if(type == 1){
      int i; char c;
      cin >> i >> c;
      i--;
      count[s[i] - 'a'].erase(i);
      s[i] = c;
      count[c - 'a'].insert(i);
    } else {
      int l, r;
      cin >> l >> r;
      l--; r--;
      int ans = 0;
      rep(i, 26){
        auto it = count[i].lower_bound(l);
        if(it != count[i].end() && *it <= r) ans++;
      }
      cout << ans << endl;
    }
  }
}

Measured memory_bytes: 24196
#include <stdio.h>

int main(void)
{
	int i, j;
	int n, m;
	char a1[100000];
	char a2[100000];
	char a3[100000];

	while(1){

		scanf("%d", &n);

		if (n == 0){
			break;
		}

		for (i = 0; i < n; i++){
			scanf("%s %s", &a1[i], &a2[i]);
		}

		scanf("%d", &m);

		for (i = 0; i < m; i++){
			scanf("%s", &a3[i]);
			for (j = 0; j < n; j++){
				if (a3[i] == a1[j]){
					a3[i] = a2[j];
					break;
				}
			}
		}

		for (i = 0; i < m; i++){
			printf("%c", a3[i]);
		}
		printf("\n");
	}

	return (0);
}

Measured memory_bytes: 684
#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, W;
    cin >> N >> W;
    vector<int> v(N);
    vector<int> w(N);
    rep(i, N){
        cin >> v[i];
        cin >> w[i];
    }
    
    // dp[i][v] := i番目までの商品のうち、価値vにできる最小の重さ
    vector<vector<long long> > dp(N+1, vector<long long>(10010, 1LL << 60));
    rep(i, N+1){
        dp[i][0] = 0;
    }
    rep(i, N){
        rep(j, 10005){
            dp[i+1][j] = min(dp[i][j-v[i]]+w[i], dp[i][j]);
        }
    }
    int ans = 0;
    rep(i, 10010){
        if(dp[N][i] <= W){
            ans = max(ans, i);
        }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 10808
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T3;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	ll n,k;
	cin >> n >> k;

	ll sum = 0;
	for(ll i = k;k <= n+1;k++){
		sum += (2 * n - k + 1) * k / 2 - k * (k-1) / 2 + 1;
		sum %= MOD;
	}

	cout << sum << endl;
}


Measured memory_bytes: 3644
N,M=map(int,input().split())

x=[-1]*N
flag=0
for i in range(M):
  s,c=map(int,input().split())
  s=s-1
  if x[s]==-1 or x[s]==c:
    x[s]=c
  else:
    flag=-1
y=[0]*N
#print(x)
if flag==-1:
  print(-1)
elif N==1:
  if x[0]==-1:
    y[0]=0
  else:
    y[0]=x[0]
  print(y[0])
elif N>=2:
  if x[0]==0:
    print(-1)
  else:
    for i in range(N):
      if x[i]==-1:
        if i==0:
          y[i]=1
        else:
          y[i]=0
      else:
        y[i]=x[i]
      
    if N==2:
      print(y[0]*10+y[1])
    else:
      print(y[0]*100+y[1]*10+y[2])

Measured memory_bytes: 3064
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node{
  int key;
  Node *next, *prev;
};

Node *nil;

Node* listSearch(int key){
  Node *cur = nil->next;
  while(cur != nil && cur->key != key){
    cur = cur->next;
  }
  return cur;
}

void init(){
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  Node *cur = nil->next;
  int isf = 0;
  while(1){
    if(cur == nil) break;
    if(isf++ > 0) printf(" ");
    printf("%d",cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t){
  if(t == nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  deleteNode(nil->next);
}

void deleteLast(){
  deleteNode(nil->prev);
}

void deleteKey(int key){
  deleteNode(listSearch(key));
}

void insert(int key){
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for(int i = 0 ; i < n ; i++){
    scanf("%s%d",com, &key);
    if(com[0] == 'i'){insert(key); np++; size++;}
    else if(com[0] == 'd'){
      if(strlen(com) > 6){
	if(com[6] == 'F') deleteFirst();
	else if(com[6] == 'L') deleteLast();
      }else{
	deleteKey(key); nd++;
      }
      size--;
    }
  }

  printList();

  return 0;
}



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

using namespace std;

using int64 = long long;

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

    vector<vector<int64>> a(n, vector<int64>(n));
    vector<vector<int64>> d(n, vector<int64>(n));

    for (int i=0; i<n; i++) {
        for (int j=0; j<n; j++) {
            cin >> a[i][j];
            d[i][j] = a[i][j];
        }
    }

    bool f = true;
    for (int k=0; k<n; k++) {
        for (int i=0; i<n; i++) {
            for (int j=0; j<n; j++) {
                if (i == k || k == j) continue;
                if (d[i][j] > d[i][k] + d[k][j]) {
                    f = false;
                } else if (d[i][j] == d[i][k] + d[k][j]) {
                    a[i][j] = 0;
                }
            }
        }
    }



    if (!f) {
        cout << -1 << endl;
        return 0;
    }

    int64 ans = 0;
    for (int i=0; i<n; i++) {
        for (int j=i+1; j<n; j++) {
            if (a[i][j] == d[i][j])
                ans += a[i][j];
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 1664
#include <iostream>

using namespace std;

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

    cin >> S;
    h = S / 3600;
    m = (S % 3600) / 60; 
    s = (S % 3600) % 60; 

    cout << h << ":" << m << ":" << s << "\n";

    return 0;
}

Measured memory_bytes: 1168
#pypyは内包表記使わない, rstrip注意
#提出前に見返すこと！
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 1000000007

    N = int(input())
    D, X = map(int, input().split())
    res = X
    for _ in range(N):
        A = int(input())
        res += (D-1)//A + 1
    print(res)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long llong;

int main(void) {
  vector<int> result(50000);
  int N;
  bool flg=false;
 
  for(int i=0;i<50000;i++) {
    result.at(i) = i*1.08;
  }

  cin >> N;

  for(int i=0;i<50000;i++) {
    if(result.at(i)==N) {
      cout << i << endl;
      flg=true;
    }
  }

  if(flg==false) cout << ":(" << endl;

  return (0);
}


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

using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(ll)(n);i>0;i--)
#define REP(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
const ll inf = 1000000001;
const ll INF = 2e18;
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);


int main() {
	int n;
	cin >> n;
	vi wa(n + 1);
	rep1(i, n) {
		int sum = 0;
		int mask = 1000000;
		int a = i;
		while (mask) {
			sum += a / mask;
			a %= mask;
			mask /= 10;
		}
		wa[i] = sum;
	}
	int ans = inf;
	rep1(i, n - 1) {
		int a = i, b = n - a;
		chmin(ans, wa[a] + wa[b]);
	}
	cout << ans << endl;
}

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

const int MAX_N = 110, MAX_K = 20;
ll dp0[MAX_N][MAX_K];
ll dp1[MAX_N][MAX_K];
int L, K;
char N[MAX_N];

int main()
{
    scanf("%s", N);
    L = strlen(N);
    for(int i = L; i > 0; --i) N[i] = N[i-1]; // 1-indexedにした
    N[0] = '0'; // 0番目を0にしても問題に影響はない
    scanf("%d", &K);

    dp1[0][0] = 1LL; // 0番目を0にしたとき、1～L番目の選び方次第でNより大きくなることがあるのでdp0[0][0] = 0
    for(int i = 1; i <= L; ++i) {
        ll k = N[i] - '0';
        dp0[i][0] = dp0[i-1][0] + (k > 0 ? dp1[i-1][0] : 0);
        dp1[i][0] = k > 0 ? 0 : dp1[i-1][0]; // k > 0のとき、dp1[i-1][0]から遷移しようにしてもかならずNより大きくなってしまうので0になる
        for(int j = 1; j <= K; ++j) {
            dp0[i][j] = 9LL*dp0[i-1][j-1] + dp0[i-1][j] 
                        + max(0LL, k-1)*dp1[i-1][j-1]
                        + (k > 0LL ? dp1[i-1][j] : 0LL);
            dp1[i][j] = k > 0 ? dp1[i-1][j-1] : dp1[i-1][j];
            
        }
    }
    printf("%lld\n", dp0[L][K] + dp1[L][K]);
    return 0;
}

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

//If a carry should be included in this addition,
//assign the carry true, otherwise, false
//If a carry is generated, true is assigned to the carry, otherwise, false
char add_digit( char c1, char c2, bool *carry ){
	char n[3];
	int s;
	int i1 = atoi(&c1);
	int i2 = atoi(&c2);

	s = i1 + i2;

	if( *carry ) s++;
	
	sprintf(n, "%d", s);
	
	if( s>=10 ){
		*carry = true;
		return n[1];
	}else{
		*carry = false;
		return n[0];
	}
}

char* read_nchar( int n ){
	char *a;
	int i;

	//'+1' is needed for '\0'
	a = (char*)malloc( sizeof(char)*(n+1) );

	memset(a, 0, sizeof(a) );

	for( i=0;; i++ ){
		
		scanf("%c", &a[i]);
		
		if( a[i] == '\n' ){
			a[i] = '\0';
			return a;
			
		}else if( i == n ){
			
			while( getchar() != '\n');
			return NULL;
			
		}
	}
}


int main(){
	int i, j, k, p;
	char *a, *b;
	int N;
	char s[82];
	int la, lb, maxl;
	bool carry;

	scanf("%d", &N);
	getchar();

	for( i=0; i<N; i++ ){

		carry = false;
		
		a = read_nchar( 80 );
		b = read_nchar( 80 );
		if( a == NULL || b == NULL ){
			printf("overflow\n");
			continue;
		}

		la = strlen(a);
		lb = strlen(b);
		maxl = (la > lb)? la : lb;
		
		s[maxl] = '\0';
		for( j=la-1, k=lb-1, p=maxl-1; j>=0 || k>=0; j--, k--, p-- ){
			if( j < 0 )	    s[p] = add_digit( '0' , b[k], &carry);
			else if( k < 0 )s[p] = add_digit( a[j], '0' , &carry);
			else            s[p] = add_digit( a[j], b[k], &carry);
		}
		if( carry == true ){
			for( j=strlen(s); j>=0; j-- ){
				s[j+1] = s[j];
			}
			s[0]='1';
		}

		if( strlen(s) > 80 ){
			printf("overflow\n");
			continue;
		}

		printf("%s\n", s);
		
	}

	return 0;
}

Measured memory_bytes: 624
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int main() {
    int L, R, d;
    cin >> L >> R >> d;
    int ans = 0;
    for (int i = L; i <= R; i++) {
        if (i % d == 0) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3616
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N, M, X;
    cin >> N >> M >> X;

    vll A(M);
    REP(i, M) cin >> A[i];

    int cnt = lower_bound(ALL(A), X) - A.begin();

    print(min(cnt, M - cnt));


    
}


Measured memory_bytes: 3648