akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

struct data{
  string name;
  vector<int> view;
  int score;
  data():score(0){}
  bool operator < (const data& d) const {
    if(score != d.score) return score < d.score;
    return name < d.name;
  }
};
const int MAX = 30;
int disp[MAX];
int n;
vector<data> V;

void init(){
  V.clear();
  fill(disp,disp+MAX,0);
}

void input(){
  for(int i = 0; i < n; i++){
    int num;
    data d;
    cin >> d.name;
    cin >> num;
    while(num--){
      int in;
      cin >> in;
      d.view.push_back(in);
      disp[in]++;
    }
    V.push_back(d);
  }
}

void solve(){
  
  for(int i = 0; i < (int)V.size(); i++)
    for(int j = 0; j < (int)V[i].view.size(); j++)
      V[i].score += n-disp[V[i].view[j]]+1;
    
  sort(V.begin(),V.end());

  cout << V[0].score << " " << V[0].name << endl;
  
}

int main(){
  
  while(cin >> n && n){
    init();
    input();
    solve();
  }
  return 0;
}

Measured memory_bytes: 1256
A, B, C, X, Y = map(int, input().split())

ans_1 = X * A + Y * B
if X > Y :
    ans_2 = Y * 2 * C + (X-Y) * A
else :
    ans_2 = X * 2 * C + (Y-X) * B
ans_3 = max(X, Y) * 2 * C

print(min(ans_1,ans_2,ans_3))


Measured memory_bytes: 2940
#include <stdio.h>

int main() {
  int c, K, output = 1;
  scanf("%d %d", &c, &K);
  for(int i = 0; i < c; i++) {
    (output+K > output*2) ? output *= 2 : output += K;
  }
  printf("%d\n", output);
  return 0;
}

Measured memory_bytes: 1736
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <stack>
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
constexpr ll MOD = 1000000007;
constexpr ll MAX = 2000;

ll S, ans;
ll fac[MAX], finv[MAX], inv[MAX];

void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM(ll n, ll k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
    ans = 0;
    cin >> S; 
    if (S >= 3)
    {
        COMinit();
        for (ll i = 1; i <= S / 3; i++)
        {
            ans += COM(S - 2 * i - 1, i - 1);
        }
    }
    cout << ans % MOD << endl;
    return 0;
}

Measured memory_bytes: 3680
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll a,b; cin >> a >> b;
    ll d = (b-a);
    ll ra = (d-1)*d/2;
    res = ra-a;
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


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


int main() {
    int x, y, z, pessoa;
    scanf("%d %d %d", &x, &y, &z);
    pessoa=x/(y+z);
    if (x%(y+z) >= z) {
       printf("%d\n", pessoa);
    } else {
        printf("%d\n", pessoa-1);
    }
    
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using i128 = boost::multiprecision::int128_t;
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const int x) { return 31-__builtin_clz(x); } // floor(log2(x))
inline int fLog2(const ll x) { return 63-__builtin_clzll(x); }
inline int cLog2(const int x) { return (x == 1) ? 0 : 32-__builtin_clz(x-1); } // ceil(log2(x))
inline int cLog2(const ll x) { return (x == 1) ? 0 : 64-__builtin_clzll(x-1); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;

V a;
VV G;
V deg;

void ng() {
  cout << "NO\n";
  exit(0);
}

int dfs(int u, int p=-1) {
  if (p != -1 && deg[u] == 1) return a[u];
  int res = a[u]<<1;
  for (int v : G[u]) if (v != p) {
    int x = dfs(v, u);
    if (x > a[u]) ng();
    res -= x;
  }
  if (res < 0 || res > a[u]) ng();
  return res;
}

int main() {
  int n; cin >> n;
  a.assign(n, 0);
  deg.assign(n, 0);
  cin >> a;

  G.assign(n, V());
  rep(i, n-1) {
    int a, b; cin >> a >> b;
    --a; --b;
    G[a].push_back(b);
    G[b].push_back(a);
    ++deg[a];
    ++deg[b];
  }

  int x = dfs(0);
  if (deg[0] == 1 && x != a[0]) ng();
  if (deg[0] != 1 && x != 0) ng();
  cout << "YES\n";
  return 0;
}


Measured memory_bytes: 16020
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] array = new int[n];
		for(int i = 0; i < array.length; i++) 
			array[i] = sc.nextInt();
		System.out.println(Arrays.stream(array).sum() -n);
	}
}

Measured memory_bytes: 30004
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }


int dp[100001][3];
int abc[100001][3];


int main() {
  int N; cin >> N;
  rep(i, N) cin >> abc[i][0] >> abc[i][1] >> abc[i][2];

  rep(i, N) rep(j, 3) rep(x, 3) {
    if (j == x) continue;
    chmax(dp[i+1][x], dp[i][j] + abc[i][x]);
  }

  int ans = 0;
  rep(i, 3) chmax(ans, dp[N][i]);
  cout << ans << '\n';
}


Measured memory_bytes: 5836
#include<stdio.h>
int main(void)
{
	int a,b,x;
	char c;
	scanf("%d %c %d",&a,&c,&b);
	while(c!='?') {
		if(c=='+') {
			x=a+b;
		}
		if(c=='-') {
			x=a-b;
		}
		if(c=='*') {
			x=a*b;
		}
		if(c=='/') {
			x=a/b;
		}
		printf("%d\n",x);
	scanf("%d %c %d",&a,&c,&b);
	}
	return 0;
}

Measured memory_bytes: 600
# coding: utf-8
# Your code here!
import sys

N = int(input())

ans = []

if N % 2 == 0:
    tmp = N + 1
else:
    tmp = N
    
for i in range(1,N+1):
    for j in range(i+1,N+1):
        if i + j != tmp:
            ans.append(str(i)+' '+str(j))
            
print(len(ans))

for a in ans:
    print(a)

Measured memory_bytes: 3588
# include <iostream>
using namespace std;
//AC, WA, TLE, or RE.
int main()
{
    string a[] = {"AC", "WA", "TLE", "RE"};
    int res[] = {0,0,0,0};
    int x;
    cin >> x;
    string n;
    for(int i = 0; i < x; i++)
    {
        cin >> n;
        for (int j = 0; j < 4; j++)
        {
            if (a[j] == n)
            {
                res[j]++;
            }
        }
    }
    for (int i = 0; i < 4; i++)
    {
        cout << a[i] << " x " << res[i] << endl; 
    }
}


Measured memory_bytes: 3592
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

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

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

    for (int i = 0; i < S.length(); i += 2) {
        cout << S[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <cstring>
using namespace std;

#define Sq(c) ((c)*(c))

const int MAX_N = 13;
const int INF = 1<<27;

int n;
double r[MAX_N];
double dp[(1<<MAX_N)][MAX_N];
double dist[MAX_N][MAX_N];

double rec(int S, int v) {
  if(dp[S][v] >= 0) return dp[S][v];
  
  if(S == (1<<n)-1 && v==0) return dp[S][v]=0;
  
  double res = INF;
  for(int u=0; u<n; u++) {
    if(!(S >> u & 1)) res = min(res, rec(S | 1 << u, u) + dist[v][u]);
  }
  return dp[S][v] = res;
}

int main() {
  
  double width;
  string str;

  while(getline(cin, str)) {
    stringstream ss(str);
    
    ss >> width;
    n = 0;
    while( ss >> r[n] ) n++;
    
    memset(dp, -1, sizeof(dp));

    for(int i=0; i<n; i++) {
      for(int j=0; j<n; j++) {
	dist[i][j] = sqrt( Sq( r[i]+r[j] ) - Sq( r[i]-r[j] ) );
      }
    }
    // テ・ツキツヲテ・ツ渉ウテ、ツクツ。テァツォツッテ」ツ?ォテヲツウツィテヲツ??
    for(int i=0; i<n; i++) {
      dist[i][n] = dist[n][i] = r[i];
    }
    n ++;
    
    if( rec(0, 0) <= width ) cout << "OK" << endl;
    else cout << "NA" << endl;
    
    // printf("%lf\n", dp[0][0]);
  }
  
  return 0;
}

Measured memory_bytes: 2072
import numpy as np
def main():
    N = int(input())
    S = list(input())
    S_W = [1 if S[i] == "W" else 0 for i in range(N)]
    S_E = [1 if S[N-i-1] == "E" else 0 for i in range(N)]
    S_W_rui = np.cumsum(S_W)
    S_E_rui = np.cumsum(S_E)
    
    #print(S_W_rui,S_E_rui)
    cnt = N
    cnt_new = N
    
    for i in range(N):
        if i == 0:
            cnt_new = S_E_rui[N-i-2]
        elif i == N-1:
            cnt_new = S_W_rui[i-1]
        else:
            cnt_new = S_W_rui[i-1] + S_E_rui[N-i-2]
        if cnt_new < cnt:
            cnt = cnt_new
            #print(cnt)
    print(cnt)
    
    
main()


Measured memory_bytes: 26648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

int main()
{
  ll H, W;
  cin >> H >> W;
  vector<vector<ll>> A(H, vector<ll>(W));
  vector<vector<ll>> B(H, vector<ll>(W));
  for (ll i = 0; i < H; i++)
  {
    for (ll j = 0; j < W; j++)
    {
      cin >> A.at(i).at(j);
    }
  }
  for (ll i = 0; i < H; i++)
  {
    for (ll j = 0; j < W; j++)
    {
      cin >> B.at(i).at(j);
    }
  }
  vector<vector<ll>> C(H, vector<ll>(W));
  for (ll i = 0; i < H; i++)
  {
    for (ll j = 0; j < W; j++)
    {
      C.at(i).at(j) = abs(A.at(i).at(j) - B.at(i).at(j));
    }
  }

  vector<vector<vector<bool>>> dp(81, vector<vector<bool>>(81, vector<bool>(160 * 160 + 10, false)));
  dp.at(0).at(0).at(80 * 160 + C.at(0).at(0)) = true;
  dp.at(0).at(0).at(80 * 160 - C.at(0).at(0)) = true;
  for (ll d = 0; d < H + W; d++)
  {
    for (ll i = 0; i < H; i++)
    {
      ll j = d - i;
      if (!(0 <= j && j < W))
        continue;
      
      //cerr << i << " " << j << endl;
      
      for (ll k = 0; k < 160 * 160 + 5; k++)
      {
        if (dp.at(i).at(j).at(k))
        {
          if (0 <= i + 1 && i + 1 < H)
          {
            dp.at(i + 1).at(j).at(k + C.at(i + 1).at(j)) = true;
            dp.at(i + 1).at(j).at(k - C.at(i + 1).at(j)) = true;
          }
          if (0 <= j + 1 && j + 1 < W)
          {
            dp.at(i).at(j + 1).at(k + C.at(i).at(j + 1)) = true;
            dp.at(i).at(j + 1).at(k - C.at(i).at(j + 1)) = true;
          }
        }
      }
      //cerr << i << " " << j << endl;
    }
  }

  ll ans = INF;
  for (ll i = 0; i < 160 * 160 + 10; i++)
  {
    if (dp.at(H - 1).at(W - 1).at(i))
      chmin(ans, abs(80 * 160 - i));
  }
  cout << ans << endl;
}

Measured memory_bytes: 23552
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
 
#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
int main(){
  int N,Q;
  while(~scanf("%d %d",&N,&Q)){
    string final_name = "kogakubu10gokan";
    int last_num=0;
    for(int i=0;i<N;i++){
      int num;
      string name;
      cin >> num >> name;
      if(num <= Q && num >= last_num){
	last_num = num;
	final_name = name;
      }
    }
    printf("%s\n",final_name.c_str());
  }
}

Measured memory_bytes: 1240
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <math.h>
#define rep(i,n) for(int i = 0; i <(n); i++)
using namespace std;
typedef long long ll;

int main(void) {
	int N, A, B, i,tmp,sum = 0, cnt = 0;

	scanf("%d %d %d", &N, &A, &B);

	for(i = 1; i <= N; i++){
		tmp = i;
		sum = 0;
		while (tmp != 0) {
			sum += tmp % 10;
			tmp /= 10;
		}
		if (A <= sum && sum <= B) {
			cnt += i;
		}
	}
	printf("%d", cnt);
	return 0;
}

Measured memory_bytes: 256
a,b,k = map(int,input().split())

for i in range(k):
    if i%2 == 0:
        if a%2 != 0:
            a -= 1
        a = a//2
        b += a
    else:
        if b%2 != 0:
            b -= 1
        b = b//2
        a += b
        
print(a,b)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <cmath>
#include <math.h>
#include <bitset>
#include <fstream>
#define int long long
#define D double
using namespace std;
int INF = 1e18;
signed main()
{
    int N;
    cin >> N;
    for (int i=1; i <= 3500; i++){
        for (int j=1; j <= 3500; j++){
            int f = 4*i*j - (i+j) * N;
            int s = N*i*j;
            if (f <= 0) continue;
            if (s % f == 0){
                int var = s / f;
                cout << i << " " << j << " " << var << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	long a[5]={};
	
	cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];

	long i=0;

	for(;i<5;i++)
	if(a[i]==0) {
		cout << i+1;
	}

}


Measured memory_bytes: 3192
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma warning(disable:4996)
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
#include <map>
#include <iomanip> 
#include <ctime>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

const double PI = 3.14159265358979323846;
const int MAX = 1e7;
const int MOD = 1e9+7;

long long fac[MAX], finv[MAX], inv[MAX];


void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(int argc, char *args[]) {
	int x, y;
	cin >> x >> y;
	if ((x + y) % 3) {
		cout << 0 << endl;
		return 0;
	}
	int n = (x + y) / 3;
	x -= n; y -= n;
	if (x < 0 || y < 0) {
		cout << 0 << endl;
		return 0;
	}
	COMinit();
	int ans = COM(n, x);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 234624
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define double long double
#define rep(i,n) for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define repii(i,a,b) for(ll i=a;i<=b;i++)
#define pb push_back
#define in insert
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define endl "\n"
int main()
{
    fastIO;
    ll n;
    cin>>n;
    n=n-1;
    ll ans=(n*(n+1));
    ans=ans/2;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    ll n, ans = 1;
    string s;
    cin >> n >> s;
    vector<int> cnt(26, 0);
    rep(i, s.size())cnt[s[i]-'a']++;
    rep(i, 26)ans = ans * (cnt[i]+1) % mod; 
    cout << ans - 1 << endl;
}   

Measured memory_bytes: 512
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H, L, R;
long long int ans;


int main() {
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	cout << "ABC" << s << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=2e5+5;

int n, ans=0;
int a[N], h[N], bit[N];

void update(int idx, int val)
{
	while(idx<=n)
	{
		bit[idx]=max(bit[idx], val);
		idx+=idx&-idx;
	}
}

int pref(int idx)
{
	int ans=0;
	while(idx>0)
	{
		ans=max(ans, bit[idx]);
		idx-=idx&-idx;
	}
	return ans;
}

int rsum(int l, int r)
{
	return pref(r) - pref(l-1);
}


int32_t main()
{
	IOS;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>h[i];
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
	{
		int maxPrev=pref(h[i]-1);
		maxPrev+=a[i];
		ans=max(ans, maxPrev);
		update(h[i], maxPrev);
	}	
	cout<<ans;
	return 0;
}

Measured memory_bytes: 4992
#

import sys
input=sys.stdin.readline

def main():
    x1,y1,x2,y2=map(int,input().split())
    x4=x1-(y2-y1)
    y4=y1+(x2-x1)
    x3=x2+(x4-x1)
    y3=y2+(y4-y1)
    print(x3,y3,x4,y4)
    
    
    
if __name__=="__main__":
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define dump(x) cout << #x << " = " << (x) << endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define SP << " " <<
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

#define int long long

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  REP(i, N) cin >> h[i];
  int ans = 0;
  for(int i = 0; i < N; i++) {
    if(h[i] >= K) { ans++; }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
const ll inf = 1e18;
const ll mod = 1e9 + 7;

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

// mod. m での a の逆元 a^(-1) を計算する。
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(){
    int k, a, b;
    cin >> k >> a >> b;
    if( b/k - (a-1)/k >= 1) cout << "OK" << endl;
    else cout << "NG" << endl;
}



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

using namespace std;

int main(){
        char a, b;
        cin>>a>>b;
        if(a=='H'){
                cout<<b<<endl;
        }
        else{
                if(b=='H'){
                        cout<<"D"<<endl;
                }
                else{
                        cout<<"H"<<endl;
                }
        }
        return 0;
}


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

int foo(int x, int n){
  if(x < 10) return 0;
  int ma = 0, temp;
  for(int i = 10;x/i; i*=10)
    ma = max((x/i)*(x%i),ma);//cout<<ma<<" "<<n<<" "<<x<<endl;
  temp = foo(ma, n+1)+1;
  if(temp == -1 || ma == x) return -1;
  else return temp;
}

int main(){
  int Q, N;
  cin>>Q;
  for(int i = 0; i < Q; i++){
    cin>>N;
    cout<<foo(N,0)<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(all(x));
#define RSORT(x) sort(rall(x));
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;
const ll inf = 1ll<<29;
const ll mod = 1000000007;
const double eps = 1e-9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int N; cin >> N;
  vi A(N); rep(i,N) cin >> A.at(i);

  int i_max;
  int max_A = 0;
  rep(i,N) {
    if(A.at(i) > max_A) {
      max_A = max(max_A, A.at(i));
      i_max = i;
    }
  }

  vi B(N);
  rep(i,N) {
    if(i!=i_max) B.push_back(A.at(i));
  }

  int max_B = *max_element(all(B));
  rep(i,N) {
    cout << (i==i_max ? max_B : max_A) << endl;
  }
}

Measured memory_bytes: 3952
import sys
read = sys.stdin.buffer.read
input=lambda :sys.stdin.readline().rstrip()
# inputs= sys.stdin.buffer.readlines
INF=float("inf")
MOD=10**9+7

#input = sys.stdin.buffer.readline
#sys.setrecursionlimit(2147483647)

#rstrip().decode('utf-8')

#import math
#import numpy as np
#import operator
#import bisect
#from heapq import heapify,heappop,heappush
#from math import gcd
#from fractions import gcd
#from collections import deque
#from collections import defaultdict
#from collections import Counter
#from itertools import accumulate
#from itertools import groupby
#from itertools import permutations
#from itertools import combinations
#from scipy.sparse import csr_matrix
#from scipy.sparse.csgraph import floyd_warshall
#from scipy.sparse.csgraph import csgraph_from_dense
#from scipy.sparse.csgraph import dijkstra

#map(int,input().split())

def main():
	n=int(input())
	s=input()
	
	ans=0
	cnt=0
	
	
	for d in range(1,n):
		cnt=0
		for i in range(n-d):
			if s[i]==s[i+d]:
				cnt+=1
				ans = max(ans, min(cnt, d))
			else:
				cnt=0
	print(ans)
	
	
	
	
	

if __name__ == '__main__':
	main()

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

int main() {
    int N; cin >> N;
    vector<vector<int> > amount(10, vector<int>(10, 0));
    for (int i = 1; i <= N; i++) {
        string n = to_string(i);
        amount[n[0] - '0'][n[n.length()-1] - '0']++;
    }
    int ans = 0;
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            ans += amount[i][j] * amount[j][i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def bubbleSort(a, n):   #n個の要素を持つ配列a
    flag = 1    #逆の隣接要素あり
    i = 0       #未ソートの先頭
    count = 0
    while flag:
        flag = 0
        for j in range(n-1, i, -1): #j n-1...i+1
            if a[j] < a[j-1]:

                a[j], a[j-1] = a[j-1], a[j]
                count += 1
                flag = 1
        i += 1
    print(' '.join(map(str, a)))
    print(count)


#配列出力用
def trace(a, n):
    output = ''
    for i in a:
        if i == a[n-1]:
            output += str(i)
        else:
            output += str(i) + ' '
    print(output)

#配列の要素数と要素の入力
n = int(input())
a = list(map(int, input().split()))

bubbleSort(a, n)


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

int main(){
    long long h,n;
    cin >> h >> n;
    int sum=0;
    int a;
    for (int i=0;i<n;i++){
        cin >> a;
        sum += a;
    }

    if (sum < h){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
using namespace std;

#define ll long long int

int main()
{
    ll a, b, k;

    cin >> a >> b >> k;
    for (int i = a; i <= b; i++)
    {
        if (i >= a && i <= b && (i <= a + k - 1 || i >= b - k + 1))
            cout << i << endl;
    }
}


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

#define v(type) vector<type> 
#define map(type1,type2) map<type1,type2>
#define INF 1000000005
#define pb push_back
#define mp make_pair
#define f0(i,n) for(i = 0; i < ( n ); i ++)
#define f1(i,n) for(i = 1; i <= ( n ); i ++)
#define f(i,m,n) for(i = ( m ); i <= ( n ); i ++)
#define nl cout<<endl

typedef long long int ll;
typedef unsigned long long int ull;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int H,N;
    cin>>H>>N;
    ll s=0;
    int i;
    f(i,1,N)
    {
        ll a;
        cin>>a;
        s=s+a;
    }
    if(s>=H)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}

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

#define llint long long

int main(void){
	llint n;cin >> n;
	llint ans=2*n;
	for(llint i=1;i<1000005;i++){
		if(n%i!=0)continue;
		ans=min(ans,i+n/i);
	}
	cout << ans -2 << endl;
	return 0;
}



Measured memory_bytes: 256
//  Copyright © 2020 Diego Garcia Rodriguez del Campo. All rights reserved.
#include<bits/stdc++.h>
#define MAX 200005
#define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0);
#define what_is(x) cerr << #x << " is " << x << endl;
#define pii pair < int , int >
#define fi first
#define se second
using namespace std;
typedef long long ll;

ll A, B;

int main()
{
    optimiza_io
    cin >> A >> B;
    cout << A * B;
    return 0;
}

// CHECAR LIMITES 

Measured memory_bytes: 3652
#include<iostream>
#include<float.h>
using namespace std;

int main(){
    double pos[4][2];
    double slope[4];
    bool zero[4];
    double temp;
    int lors;
    bool result;
    int i, j;
    char comma;
    while(cin >> pos[0][0]){
        cin >> comma >> pos[0][1];
        for(i=1;i<4;i++){
            for(j=0;j<2;j++){
                cin >> comma >> pos[i][j];
            }
        }
        for(i=0;i<4;i++){
            temp = pos[i%4][0] - pos[(i+1)%4][0];
            if(temp == 0){
                slope[i] = DBL_MAX;
                zero[i] = true;
            }else{
                slope[i] = (pos[i%4][1] - pos[(i+1)%4][1])/temp;
                zero[i] = false;
            }
        }
        result = true;
        for(i=0;i<2;i++){
            if(slope[0] > slope[1]){
                lors = 0;
            }else{
                lors = 1;
            }
            for(j=1;j<4;j++){
                if(slope[j%4] > slope[(j+1)%4] && !lors){
                    result = false;
                    break;
                }else if(slope[j%4] < slope[(j+1)%4] && lors){
                    result = false;
                    break;
                }else{
                    lors = 1 - lors;
                }
            }
            for(j=0;j<4;j++){
                if(zero[j]){
                    slope[j] = DBL_MIN;
                }
            }
        }
        if(result){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
}

Measured memory_bytes: 0
n = int(input())
arr = list(map(float,input().split()))

dp=[]
for i in range(n+1):
    dp.append([0]*(n+1))
dp[1][0]=(1-arr[0])
dp[1][1]=arr[0]

for i in range(2,n+1):
    for j in range(0,i+1):
        dp[i][j]= dp[i-1][j-1]*arr[i-1] + dp[i-1][j]*(1-arr[i-1])
ans=0
for i in range(n//2+1,n+1):
    ans+=dp[n][i]

print(ans)




Measured memory_bytes: 261768
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	char c;
	cin >> c;

	co(char(c + 1));


	Would you please return 0;
}

Measured memory_bytes: 256
d, n = map(int, input().strip().split())


def judge(num):
    count = 0
    while True:
        if count == d:
            return num % 100 != 0

        if num % 100 == 0:
            count += 1
            num //= 100
        else:
            return False


found = 0
num = 1
while True:
    if judge(num):
        found += 1

    if found == n:
        print(num)
        break

    num += 1


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

typedef long long ll;
#define pa pair<int, int> 
#define pal pair<long long, long long>
#define pad pair<double, double>
#define pb push_back
#define mp make_pair
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}

typedef vector<bool> bvec;
typedef vector<int> ivec;
typedef vector<long long> lvec;
typedef vector<double> dvec;
typedef vector<pa> pvec;

typedef vector< vector<bool> > bmat;
typedef vector< vector<int> > imat;
typedef vector<string> svec;
typedef vector< vector<string> > smat;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int  h, n;
    cin >> h >> n;
    ivec a(n), b(n);
    for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
    //int ma = *max_element(a.begin(), a.end());
    //int nh = h+ma;
    ivec dp(h+1, 1e8+1);
    dp[0] = 0;
    for (int i = 1; i < h+1; i++){
        for (int j = 0; j < n; j++) dp[i] = fmin(dp[i], dp[fmax(0, i-a[j])] + b[j]);
    }
    //cout << *min_element(dp.begin()+h, dp.end()) << endl;
    cout << dp[h] << endl;

}


Measured memory_bytes: 256
def koch(p,q,n):
    if n==0:
        return [p]
    else:
        c1=[(p[0]*2+q[0])/3,(p[1]*2+q[1])/3]
        c3=[(p[0]+q[0]*2)/3,(p[1]+q[1]*2)/3]
        if p[0]<q[0]:
            if p[1]==q[1]:
                c2=[(p[0]+q[0])/2,p[1]+(q[0]-p[0])/2/3**0.5]
            elif p[1]<q[1]:
                c2=[p[0],(p[1]+q[1]*2)/3]
            else:
                c2=[q[0],(p[1]*2+q[1])/3]
        else:
            if p[1]==q[1]:
                c2=c2=[(p[0]+q[0])/2,p[1]+(q[0]-p[0])/2/3**0.5]
            elif p[1]<q[1]:
                c2=[q[0],(p[1]*2+q[1])/3]
            else:
                c2=[p[0],(p[1]+q[1]*2)/3]
        return koch(p,c1,n-1)+koch(c1,c2,n-1)+koch(c2,c3,n-1)+koch(c3,q,n-1)


n=int(input())
ans=koch([0,0],[100,0],n)+[[100,0]]
for i in ans:
    print(*i)


Measured memory_bytes: 6204
#import math
#import bisect
#import numpy as np
#import itertools
#import copy
import sys

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    n, a, b = list(map(int,ipti().split()))
    print(min(a*n, b))

if __name__ == '__main__':
    main()

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

int n,k,c;
string s;
int l[200001],r[200001];
int main(){
    cin>>n>>k>>c>>s;
    int pre=-1000000,cnt=0;
    rep(i,n){
        if(s[i]=='o'&&pre+c<i){
            l[cnt]=i;pre=i;
            ++cnt;
            if(cnt>=k) break;
        }
    }
    pre=1000000,cnt=0;
    for(int i=n-1;i>=0;--i){
        if(s[i]=='o'&&pre-c>i){
            r[k-cnt-1]=i;pre=i;
            ++cnt;
            if(cnt>=k) break;
        }
    }
    rep(i,k)if(r[i]==l[i])cout<<r[i]+1<<endl;
    return 0;
}

Measured memory_bytes: 5208
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//vc Alp ={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//cout<<""<<endl;
int main(){
  string s;cin>>s;
  int st=0,en =s.size()-1;
  rep(i,en+1){
    if(s[i]=='A'){
      st=i;break;
    }
  }
  for(int i=en;i>=0;i--){
    if(s[i]=='Z'){
      en=i;
      break;
    }
  }
  cout<<en-st+1<<endl;
  
}   





Measured memory_bytes: 640
import java.io.*;
import java.util.*;
import java.lang.Math.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve(args);
    }

    public void solve(String[] args) {
        int[][] g =
            {
                {1, 3, 5, 7, 8, 10, 12},
                {4, 6, 9, 11},
            };
        MyScanner scanner = new MyScanner();
        int x = scanner.nextInt();
        int y = scanner.nextInt();

        for (int i = 0; i < 2; i++) {
            boolean findX = false;
            boolean findY = false;
            for (int l = 0; l < g[i].length; l++) {
                if (g[i][l] == x) findX = true;
                if (g[i][l] == y) findY = true;
            }
            if (findX && findY) {
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";

        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String line = br.readLine();
            while (line.equals("")) {
                line = br.readLine();
            }
            s = line.split(reg, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() {
            try {
                return Integer.parseInt(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }

        public double nextDouble() {
            try {
                return Double.parseDouble(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }

        public long nextLong()  {
            try {
                return Long.parseLong(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }
    }
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<int> vi;
typedef vector<ll> vl;
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}

int main (){
    int n,k;
    cin >> n >> k;
    vi h(n);
    vi cost(n);
    rep(i,n) cin >> h[i];
    rep(i,n){
        if(i==0) cost[i]=0;
        else{
            int st=max(0,i-k);
            for(int j=st;j<i;j++){
                if(j==st) cost[i]=abs(h[i]-h[j])+cost[j];
                else{
                    cost[i]=min(cost[i],cost[j]+abs(h[i]-h[j]));
                }
            }
        }
    }
    cout << cost[n-1] <<endl;

    return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define c(P)        cout<<P<<"\n"
#define dbg(P)      cout<<P<<" "
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,x,n)   for(ll i=x;i<n;i++)
#define frr(i,x,n)  for(ll i=n-1;i>=x;i--)


const ll N   =  500005;
const ll mod = 1e9 + 7;

using namespace std;
void add(ll &a,ll b)
{
  a+=b;
  if(a>=mod)
    a-=mod;
}
void sub(ll &a,ll b)
{
  a-=b;
  if(a<0)
    a+=mod;
}
void solve()
{
// string s;
  ll n,m,k,x=0,y=0,c=0,q,ans=0;
  cin>>n>>k;
  std::vector<ll> a(k+1);
  a[0] =1;
  for (ll i = 0; i < n; ++i)
  {
     c =0 ;
     std::vector<ll> b(k+10);
      cin>>x;
  for(ll j = k;j>=0;--j)
  {   
      ll L = j +1;
      ll R = j + min(x,k-j);
    if(L<=R)
    {
      add(b[L]  ,a[j]);
      if(R+1<=k)
      sub(b[R+1],a[j]);
    }
  }
  for (int i = 0; i <= k; ++i)
  {
    add(c  ,b[i]);
     add(a[i]  ,c);
  }

  }
  
  cout<<a[k]<<" ";
}

signed main(){

      ios_base::sync_with_stdio(false);   
      cin.tie(NULL);
      ll T=1;
      //cin>>T;
      while(T--)
      {
      solve();
      }
      return 0;
    }


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

int main() {
	int p, q, r;
	cin >> p >> q >> r;
	int a = p + q;
	int b = q + r;
	int c = r + p;
	cout << min(min(a, b), c) << endl;

	return 0;
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int NN = int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(' ');
            int[] ina = str.Select(int.Parse).ToArray();
            int[] jna = ina;

            int i = 0;
            int loop = 0;

            while (loop == 0)
            {
                i++;

                for(int j = 0 ; j < NN ; j++)
                {
                    if(ina[j]%2 == 0)
                    {
                        ina[j] = ina[j] / 2;
                    }
                    else
                    {
                        loop = 1;
                    }
                }
              
            }

            Console.WriteLine(i - 1);

        }
    }
 }


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

typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

// cout<<fixed<<setprecision(10);

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 n, k, s; cin >> n >> k >> s;

    int ans[100000];
    rep(i, 100000) ans[i] = s;

    rep(i, n){
        if(i<k) continue;
        s==1e9 ? ans[i]=s-1:ans[i]=s+1;
    }
    rep(i, n){
        cout << ans[i];
        if(i!=n-1) cout << " ";
    }
    cout << endl;
}



Measured memory_bytes: 1664
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

  public static void main(String[] args) throws Exception {
    try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
      int answer = accept(reader.readLine(), reader.readLine());
      System.out.println(answer);
    }
  }

  static int accept(String nl, String hsl) {
    int n = Integer.parseInt(nl);
    int[] h = new int[n];

    String[] hValues = hsl.split(" ");
    Arrays.setAll(h, i -> Integer.parseInt(hValues[i]));
    return eval(h);
  }

  static int eval(int... h) {
    int c = 0;
    int max = 0;
    for (int n : h) {
      if (max <= n) {
        max = n;
        ++c;
      }
    }
    return c;
  }

}


Measured memory_bytes: 27988
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (a, b) = (v[0], v[1]);
    let mut grid1 = vec![vec![]; a];
    let mut grid2 = vec![vec![]; b];

    for i in 0..a {
        grid1[i] = read::<String>().chars().collect::<Vec<_>>();
    }
    for i in 0..b {
        grid2[i] = read::<String>().chars().collect::<Vec<_>>();
    }

    for origin_y in 0..a - b + 1 {
        'outer: for origin_x in 0..a - b + 1 {
            for offset_y in 0..b {
                for offset_x in 0..b {
                    if grid1[origin_y + offset_y][origin_x + offset_x] != grid2[offset_y][offset_x]
                    {
                        continue 'outer;
                    }
                }
            }
            println!("Yes");
            return;
        }
    }
    println!("No");
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include<stdio.h>

/* 自然数 a > b を確認・入替 */
long gcd(long a, long b){
  long tmp,r;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  
  return b;
}
  
int main(){
  int i,j,k;
  int N;
  
  scanf("%d",&N);
  long A[N];
  long max=0,ggcd,ggcdk,ggcdz;
  long gz[N],gk[N],g[N];
  
  for(i=0;i<N;i++){
    scanf("%ld ",&A[i]);
  }
  gz[0]=A[0];
  gk[N-1]=A[N-1];
  for(i=1;i<N;i++){
    gz[i] = gcd(gz[i-1],A[i]);
    gk[N-1-i] = gcd(gk[N-i],A[N-1-i]);
    
  }
  
  for(i=0;i<N;i++){
    if(i==0)
      g[i] = gk[1];
    else if(i== (N-1))
      g[i] = gz[N-2];
    else
    g[i] = gcd(gz[i-1],gk[i+1]);
    if(g[i] > max)
      max = g[i];
  }
  printf("%ld\n",max);
  return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void solve()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll p,q,r,s,ans1=0,ans2=0,ans=0;
    p=a*c;
    q=a*d;
    r=b*c;
    s=b*d;

    ans1=max(p,q);
    ans2=max(r,s);
    ans=max(ans1,ans2);
    cout<<ans;

}
int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 3640