akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)

/* short names and const
using ll = long long;
using vll = vector<long long>;
using df = vector<vector<long long>>;
df data(n, vector<long long>(m));
const int MOD = 1e9 + 7;
int INF = numeric_limits<int>::max();
*/

/* Boost!
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
using boost::algorithm::split; // split(result, s, boost::is_any_of(","));
#include <boost/algorithm/string/join.hpp>
using boost::algorithm::join; // string s = join(arr, "");
#include <boost/algorithm/string/replace.hpp>
using boost::algorithm::replace_all; // replace_all(s, "AtCoder", "A");
#include <boost/range/algorithm.hpp> // boost::sort(arr)
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;
*/

/* print(arr)
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}
*/

/* fast cin and precise cout
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  getline(cin, s);
  cout << fixed << setprecision(15);
*/

/* sum function
int sum(vector<int> &arr) {
  int res = accumulate(arr.begin(), arr.end(), 0);
  return res;
}
*/

/* if in function
template <class T>
bool contain(vector<T> &vec, T find_it) {
  auto it = find(vec.begin(), vec.end(), find_it);
  return it != vec.end();
}

bool contain(string &str, char c) {
  auto it = find(str.begin(), str.end(), c);
  return it != str.end();
}
*/

bool contain(string &str, char c) {
  auto it = find(str.begin(), str.end(), c);
  return it != str.end();
}

int main() {
  string s, t;
  cin >> s >> t;
  bool ans = false;
  rep(i, s.size()) {
    if (s == t) ans = true;
    s = s.back() + s.substr(0, s.size() - 1);
  }
  cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,ans,a[100005];
int main(){
	cin >> n;
	for(int i=0;i<n;i++)
		cin >> a[i];
	for(int i=0;i<n;i++){
		ans+=a[i]/2;
		a[i]%=2;
		if(a[i]==1 and a[i+1]>0)
			ans++,a[i]--,a[i+1]--;
	}
	cout << ans;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
// #define int long long
 
/* short */
#define pb push_back
#define print(x) cout << x << '\n'
 
/* REPmacro */
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
 
/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;

/* const */
const int INF = INT_MAX;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

/* func */
inline bool is_uruu(int y) {return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));}

signed main()
{
  ios::sync_with_stdio(false);
  int n;

  cin >> n;
  vi t(n + 1, 0); 
  REP(i, n * (n - 1) / 2){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (c < d) t[b] += 3;
    else if (c > d) t[a] += 3;
    else t[a]++, t[b]++;
  }
  
  REPS(i, 1, n + 1){
    int r = 1;
    REPS(j, 1, n + 1){
      if (t[i] < t[j]) r++;
    }
    print(r);
  }

  return (0);
}

Measured memory_bytes: 1204
#include<iostream>
using namespace std;
int main()
{
    int a,b,c,x;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> x;

    int pattern_cnt = 0;
    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            for(int k=0;k<=c;k++){
                int sum = (500*i)+(100*j)+(50*k);
                if(x == sum) pattern_cnt++;
            }
        }
    }

    cout << pattern_cnt << endl;
    return 0;
}

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    // string ans = (b - a == c - b) ? "YES" : "NO";
    // cout << ans << endl;

    cout << (b - a == c - b ? "YES" : "NO") << endl;

    return 0;
}

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

#include <fstream>
using namespace std;

const int INF = 1001001001;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  /*
     ifstream in("input.txt");
     cin.rdbuf(in.rdbuf());
  //*/
  long long N, K;
  cin >> N >> K;
  vector<vector<int>> dl(60, vector<int>(N));
  for(int i = 0; i < N; i++){
    cin >> dl[0][i];
    dl[0][i]--;
  }
  for(int i = 1; i < 60; i++){
    for(int j = 0; j < N; j++){
      dl[i][j] = dl[i-1][dl[i-1][j]];
    }
  }
  int now = 0;
  for(int i = 0; i < 60; i++){
    if(K>>i&1ll){
      now = dl[i][now];
    }
  }
  cout << now + 1<<endl;
}


Measured memory_bytes: 50956
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,ans;
  string str;
  cin>>n>>str;
  ans=1;
  for(int i=0; i<n-1; i++){
    if(str.at(i)!=str.at(i+1)){
      ans=ans+1;
    }
  }
  cout<<ans;
}

Measured memory_bytes: 512
#include <iostream>
#include <math.h>
using namespace std;

int main(){
    double odd=0;
    double N;
    cin>>N;
    for (int i; i<=N; i++) {
        if(i%2==1){
            odd += 1;
        }
    }
    cout<<odd/N<<endl;
    return 0;
}

Measured memory_bytes: 256
from fractions import gcd

'''
https://img.atcoder.jp/abc109/editorial.pdf
答えは gcd(|X − x1|, |X − x2|, ..., |X − xN |)
'''


N, X = map(int, input().split())
x = list(map(int, input().split()))

#print(x)

A = [0] * N
for i in range(N):
    A[i] = abs(X - x[i])

#print(A)


S = [0] * (N+1)
S[0] = A[0]
for i in range(1, N):
    S[i] = gcd(S[i-1], A[i])

S.pop()
print(min(S))

Measured memory_bytes: 16236
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int R = sc.nextInt();

      if(N >= 10){
    System.out.println(R);
      }else{
	System.out.println(100*(10-N)+R);
      }
      }
}


Measured memory_bytes: 22868
n, a, b = map(int, input().split())
mod = 10**9+7
ca = 1
cb = 1
aa = 1
bb = 1
for i in range(1, a+1):
    aa*=i
    aa%=mod
for i in range(1, b+1):
    bb*=i
    bb%=mod
for i in range(n-a+1, n+1):
    ca*=i
    ca%=mod
for i in range(n-b+1, n+1):
    cb*=i
    cb%=mod
ca*=pow(aa, mod-2, mod)
ca%=mod
cb*=pow(bb, mod-2, mod)
cb%=mod
ans = (pow(2, n, mod)-1-ca-cb)%mod
print(ans)

Measured memory_bytes: 39792
A, B, C, X, Y = map(int, input().split())
c = C / 2
money = 0
if X > Y:
    m = X
    M = A
    f = Y
    F = B
else:
    m = Y
    M = B
    f = X
    F = A

if A + B > 2 * C:
    money = C * f * 2
    m = m - f
    f = 0

if F > 2 * C: money += f * 2 * C
else: money += f * F

if M > 2 * C: money += m * 2 * C
else: money += m * M

print(money)

Measured memory_bytes: 3064
n,m,k=map(int,input().split())

a=list(map(int,input().split()))
b=list(map(int,input().split()))


a_pre,b_pre=[0],[0]

for i in range(n):
	a_pre.append(a_pre[i]+a[i])

for i in range(m):
	b_pre.append(b_pre[i]+b[i])

ans,j=0,m
for i in range(n+1):
	if a_pre[i]>k:
		break
	while b_pre[j]>k-a_pre[i]:
		j-=1

	ans=max(ans,i+j)

print(ans)


Measured memory_bytes: 47448
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 2e9;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> ans(n, 0);
    int x, y;
    for (int i = 0; i < m; i++)
    {
        cin >> x >> y;
        ans[x - 1]++;
        ans[y - 1]++;
    }
    for (int i = 0; i < n; i++)
    {
        cout << ans[i] << endl;
    }
}

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

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll MOD = 998244353;
 
////////////////////////////////////////////////////////////////////

const int N = 1e5 + 5;

int n, q, c, P[N];
ll m;
vector<pii> E;

int GetPar(int v) { return P[v] == v ? v : P[v] = GetPar(P[v]); }
void Merge(int v, int u) {
	v = GetPar(v), u = GetPar(u);
	if (v == u) return;
	P[v] = u;
	c--;
}

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	mt19937 Rnd(time(0));
	
	cin >> n >> m >> q; c = n;
	for (int i = 0; i < n; i++) P[i] = i;
	while (q--) {
		int v, u, c; cin >> v >> u >> c;
		if (c) E.push_back(make_pair(v, u));
		else Merge(v, u);
	}
	if (m == n - 1) die((sz(E) ? "No" : "Yes"));
	for (pii e : E) if (GetPar(e.first) == GetPar(e.second)) die("No");
	cout << (m > n - c + 1LL * c * (c - 1) / 2 ? "No" : "Yes") << endl;

	return 0;
}


Measured memory_bytes: 1784
n = int(input())
left = 1e9
right = -1
A = list(map(int, input().split()))
'''
A = [input() for i in range(n)]
for i in range(n) :
    A = list(map(int, input().split()))'''
for i in range(n) :
    left = min(A[i], left)
    right = max(A[i], right)
print(right - left)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000

using vi = vector<int>;


int main() {

	int a, b;

	cin >> a >> b;

	cout << (a*b)/2 << endl;

	return 0;
}

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

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

  int l, r;
  int sum = 0;
  for(int i = 0;i < N; ++i){
    cin >> l >> r;
    sum += (r - l) + 1;
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <array>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define all(c) begin(c), end(c)
#define dump(c) cerr << "> " << #c << " = " << (c) << endl
#define tr(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef pair<int,int> pii;

const int INF = 1 << 29;
const double EPS = 1e-10;


int main() {
  array<bool, 1000000> is_p;
  fill(all(is_p), true);

  is_p[0] = is_p[1] = false;
  for (int i = 2; i * i < (int)is_p.size(); i++) if (is_p[i])
    for (int j = i * 2; j < (int)is_p.size(); j += i) is_p[j] = false;

  for (int A, D, N; cin >> A >> D >> N, (A | D | N) != 0; ) {
    int cnt = 0;
    int d;
    rep(i, INF) {
      d = A + i * D;
      if (is_p[d]) cnt++;
      if (cnt == N) break;
    }

    cout << d << endl;
  }
  
  
  return 0;
}

Measured memory_bytes: 2136
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		Map m = new HashMap<String,Integer>();
		for(int i = 0 ; i < n ; i++) {
			String s = br.readLine();
			if(m.containsKey(s)) {
				m.put(s,(int) m.get(s)+1);	
			}else {
				m.put(s, 1);
			}
		}
		int max =getMax(m);
		ArrayList<String> keylist = new ArrayList<String>();
		for(Object key : m.keySet()) {
			if(max == (int) m.get(key)) {
				keylist.add((String) key);
			}	
		}
		Collections.sort(keylist);
		for(String str : keylist) {
			System.out.println(str);
		}
		
	}
 	public static int getMax(Map<String ,Integer> m ) {
		int res = 0;
		for(Object key : m.keySet()) {
			res = Math.max(res, m.get(key));
		}
		return res;
	}

}


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


int dp__[100];

//最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x % y);
}
//最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//フィボナッチ数列
//配列dpを-1で初期化する
int fib(int n){
  if(n == 0 || n == 1) return dp__[n] = 1;
  if(dp__[n] != -1) return dp__[n];
  return dp__[n] = fib(n - 1) + fib(n - 2);
}
//階乗計算(factorial)
int fact(int n){
  if(n = 1) return 1;
  return n * fact(n - 1);
}
//累乗計算(Exponentiation)
//x**y
ll expo(int x, int y){
  ll ans = 1;
  rep(i, y){
    ans *= x;
  }
  return ans;
}
//桁数
int keta(ll x){
  if(x == 0) return 1;
  int res = 0;
  while(x){
    x /= 10;
    res++;
  }
  return res;
}


int main(){
  int a, b, t;
  cin >> a >> b >> t;
  int ans = 0;
  for(int i = a; i < t+0.5; i += a){
    ans += b;
  }
  cout << ans << endl;
}


/*





















*/


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

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

  if(S.size() <= K)
    cout << S << endl;
  else{
    for(int i = 0; i < K; i++){
      cout << S.at(i);
    }
    cout << "..." << endl;
  }
}

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl

const int MN = 100010;
const int INF = INT_MAX;

int N, K;
int h[MN];
int dp[MN];

int main() {
    rep(i, MN) dp[i] = INF;

    cin >> N >> K;
    dp[0] = 0;

    rep(i, N) {
        cin >> h[i];
    }

    rep(i, N) {
        for (int j = max(0, i - K); j < i; ++j) {
            dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
        }        
    }
    cout << dp[N-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		
		while(h != 0 || w != 0){

			StringBuilder sb = new StringBuilder();

			for(int i = 0; i < h; i++){

				for(int j = 0; j < w; j++){
					sb.append("#");
				}
				sb.append("\n");

			}
			System.out.println(sb);

			h = sc.nextInt();
			w = sc.nextInt();
		}
	}
}

Measured memory_bytes: 20820
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<LL> vl;
typedef vector<vl> vvl;
 
double EPS = 1e-9;
int INF = 1000000005;
long long INFF = 1000000000000000005LL;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
 
#ifdef TESTING
  #define DEBUG fprintf(stderr,"====TESTING====\n")
  #define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
  #define debug(...) fprintf(stderr, __VA_ARGS__)
#else
  #define DEBUG 
  #define VALUE(x)
  #define debug(...)
#endif
 
#define FOR(a,b,c) for (int (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define FORD(a,b,c) for (int (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (int (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define REP(i,n) FOR(i,0,n)
#define REPN(i,n) FORN(i,1,n)
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define SQR(x) ((LL)(x) * (x))
#define RESET(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(),v.end()
#define ALLA(arr,sz) arr,arr+sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr,sz) sort(ALLA(arr,sz))
#define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)
 
inline string IntToString(LL a){
  char x[100];
  sprintf(x,"%lld",a); string s = x;
  return s;
}
 
inline LL StringToInt(string a){
  char x[100]; LL res;
  strcpy(x,a.c_str()); sscanf(x,"%lld",&res);
  return res;
}
 
inline string GetString(void){
  char x[1000005];
  scanf("%s",x); string s = x;
  return s;
}
 
inline string uppercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
  return s;
}
 
inline string lowercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
  return s;
}
 
inline void OPEN (string s) {
  #ifndef TESTING
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
  #endif
}


int N;
int A[100000];
void solve() {
  int ans = 0;
  bool flag = 1;
  for ( int i = 0; flag; i++) {
    flag = 0;
    for ( int j = N - 1; j >= i + 1; j--) {
      if (A[j] < A[j - 1]) {
        swap(A[j], A[j - 1]);
        flag = 1;
        ans++;
      }
    }
  }
  for (int i = 0; i < N; i++){
    if (i != 0) {
      cout << " ";
    }
    cout << A[i];
  }
  cout << endl;
  cout << ans << endl;
}

int main() {
  cin >> N ;
  REP(i, N) {
    cin >> A[i];
  }

  solve();

  return 0;
}

Measured memory_bytes: 3124
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <iomanip>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;

char in[20][20];
vector<int> v;
const int K=100*1000;
int dp[2][1<<20];
int M,N;
int main() {
  scanf("%d%d",&M,&N);
  int ret=1;
  for(int i=0;i<M;i++){
    scanf("%s",in[i]);
    for(int j=0;j<N;j++){
      if(in[i][j]=='?'){
        ret*=3;
        ret%=K;
      }
    }
  }
  auto cur=dp[0];
  auto nex=dp[1];
  cur[0]=1;
  for(int i=0;i<(1<<N);i++){
    bool ok=true;
    for(int j=0;j<N-1;j++){
      if(i&(1<<j)&&(i&(1<<(j+1)))){
        ok=false;
        break;
      }
    }
    if(ok){
      v.push_back(i);
      ////cout << i << endl;
    }
  }
  for(int i=0;i<M;i++){
    for(int j=0;j<N;j++){
      //cout << i << ", " << j << endl;
      for(auto k:v){
        int p0=(k>>1);
        int p1=(k>>1)|(1<<(N-1));
        int sj,so,si;
        if((k&1)==0){
          sj=0;
        }
        else{
          sj=cur[p0]+cur[p1]+cur[p0|1]+cur[p1|1];
        }
        if((k&1)==1){
          so=0;
        }
        else if(j==0&&(k&2)){
          so=0;
        }
        else{
          so=cur[p0]+cur[p1];
          if (j == 0) {
            so += cur[p0|1]+cur[p1|1];
          }
        }
        if((k&1)==1){
          si=0;
        }
        else if(p0&1){
          si=0;
        }
        else{
          si=cur[p0] + cur[p0|1];
        }
        switch(in[i][j]){
        case 'J':nex[k]=sj;break;
        case 'O':nex[k]=so;break;
        case 'I':nex[k]=si;break;
        default:nex[k]=sj+so+si;break;
        }
        nex[k]%=K;
      }
      swap(nex,cur);
    }
  }
  int ret1=0;
  for(auto k:v){
    ret1+=cur[k];
    ret1%=K;
  }
  printf("%d\n",(ret+K-ret1)%K);
}


Measured memory_bytes: 4552
def resolve():
  N, T = map(int, input().split())
  t = list(map(int, input().split()))
  ans = 0
  till = 0
  for now in t:
    if till > now:
      ans -= till - now
    till = now + T
    ans += T
  print(ans)
  return

if __name__ == "__main__":
  resolve()


Measured memory_bytes: 30676
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <climits>
#include <cmath>
#include <unordered_map>

using namespace std;

typedef long long ll;


int main(void) {
  int n, k;
  cin >> n >> k;
  cout << (n - k + 1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
	int x,a;
	cin >> x >> a;
	if(x < a) cout << 0 << endl;
	else cout << 10 << endl;
}

Measured memory_bytes: 256
/*I wanna be the very best, like no one ever was...*/
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	int n; cin >> n;
	vector <ll> p, m;
	for(int i = 0; i < n; i ++) {
		ll x, y;
		cin >> x >> y;
		p.push_back(x + y);
		m.push_back(x - y);
	}
	sort(p.begin(), p.end());
	sort(m.begin(), m.end());
	cout << max(p.back() - p[0], m.back() - m[0]);
	
	return 0;
}

Measured memory_bytes: 6664
open System
open System.Collections.Generic

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f
    let readChars() = read string |> Seq.toArray
    let readInts() = readChars() |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

[<AutoOpen>]
module Cout =
    let writer = new IO.StreamWriter(new IO.BufferedStream(Console.OpenStandardOutput()))
    let print (s: string) = writer.Write s
    let println (s: string) = writer.WriteLine s
    let inline puts (s: ^a) = string s |> println

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

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

let main() =
    let n = read int
    let a = reada int |> Array.filter (fun x -> x % 2 = 0)
    let ok = a |> Array.forall (fun x -> x % 3 = 0 || x % 5 = 0)
    if ok then "APPROVED" else "DENIED"
    |> puts
    ()

// -----------------------------------------------------------------------------------------------------
main()
writer.Dispose()


Measured memory_bytes: 13268
#include<stdio.h>
int main()
{
	int n,a,b,x;
	scanf("%d %d %d",&n,&a,&b);
	x=n*a;
	if(x>=b){
		printf("%d\n",b);
	}
	else{
		printf("%d\n",x);
	}
	return 0;
}


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

int main()
{
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; ++i)
		cin >> a[i];
	auto mm = minmax_element(a.begin(), a.end());
	auto ans = numeric_limits<int64_t>::max();
	for (int i = *mm.first; i <= *mm.second; ++i) {
		int x = i;
		int64_t v = 0;
		for (int j = 0; j < N; ++j) {
			int y = a[j];
			if (x != y) {
				v += (y - x) * (y - x);
			}
		}
		ans = min(ans, v);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n = gets.to_i
results = {}
n.times do
  str = gets.chomp.chars.sort.join
  if results[str].nil?
    results[str] = 1
  else
    results[str] += 1
  end
end

sum = 0
results.each do |key, value|
  if value >= 2
    sum += value * (value-1) / 2
  end
end

puts sum

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

uint64_t solve(vector<int>&v,uint64_t sum=1,int i=0,int size=0){
	if(i==3)return sum;
	else if(size==v.size())return 0;
	return solve(v,sum*v.at(size),i+1,size+1)+solve(v,sum,i,size+1);
}

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int>a(5,0);
	for(int i=0;i<n;++i){
		string s; cin>>s;
		if(s.front()=='M')++a.at(0);
		else if(s.front()=='A')++a.at(1);
		else if(s.front()=='R')++a.at(2);
		else if(s.front()=='C')++a.at(3);
		else if(s.front()=='H')++a.at(4);
	}
	uint64_t ans=0;
	vector<int>v;
	for(auto&i:a)if(i>0){++ans;v.emplace_back(i);}
	if(ans==3)ans=1;
	else if(ans>2)ans*=(ans-1)/2;
	cout<<solve(v)<<"\n"s;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  set<int> s;
  for (int i = 0; i < (int)3; ++i) {
    int a;
    cin >> a;
    s.insert(a);
  }
  cout << s.size() << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll solve(ll N){
    ll DP[150][4][4][4];

    int A = 0, C = 1, G = 2;

    if(N == 3) return 4*4*4 - 3;

    rep(i,4) rep(j,4) rep(k,4) DP[3][i][j][k] = 1;

    repi(n,3,N) rep(i,4) rep(j,4) rep(k,4){    
        if(n >= 4) rep(m,4){
            DP[n][i][j][k] += DP[n-1][m][i][j];
            if(m == A && j == G && k == C) DP[n][i][G][k] = 0;
            if(m == A && i == G && k == C) DP[n][i][j][k] = 0;
        }
        DP[n][A][G][C] = 0;
        DP[n][A][C][G] = 0;
        DP[n][G][A][C] = 0;
        DP[n][i][j][k] %= MOD;
    }

    ll ans = 0;
    rep(i,4) rep(j,4) rep(k,4) ans += DP[N][i][j][k], ans %= MOD;
    return ans;
}

int main(){
    ll N; cin >> N;
    pr(solve(N));
    return 0;
}


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

int main() {
	string S;
	int N;
	cin >>N>>S;
	for (int i = 0; i < S.size(); i++) {
		for (int in = 0; in < N; in++) {
			if (S.at(i) == 'A') {
				S.at(i) = 'B';
			}
			else if (S.at(i) == 'B') {
				S.at(i) = 'C';
			}
			else if (S.at(i) == 'C') {
				S.at(i) = 'D';
			}
			else if (S.at(i) == 'D') {
				S.at(i) = 'E';
			}
			else if (S.at(i) == 'E') {
				S.at(i) = 'F';
			}
			else if (S.at(i) == 'F') {
				S.at(i) = 'G';
			}
			else if (S.at(i) == 'G') {
				S.at(i) = 'H';
			}
			else if (S.at(i) == 'H') {
				S.at(i) = 'I';
			}
			else if (S.at(i) == 'I') {
				S.at(i) = 'J';
			}
			else if (S.at(i) == 'J') {
				S.at(i) = 'K';
			}
			else if (S.at(i) == 'K') {
				S.at(i) = 'L';
			}
			else if (S.at(i) == 'L') {
				S.at(i) = 'M';
			}
			else if (S.at(i) == 'M') {
				S.at(i) = 'N';
			}
			else if (S.at(i) == 'N') {
				S.at(i) = 'O';
			}
			else if (S.at(i) == 'O') {
				S.at(i) = 'P';
			}
			else if (S.at(i) == 'P') {
				S.at(i) = 'Q';
			}
			else if (S.at(i) == 'Q') {
				S.at(i) = 'R';
			}
			else if (S.at(i) == 'R') {
				S.at(i) = 'S';
			}
			else if (S.at(i) == 'S') {
				S.at(i) = 'T';
			}
			else if (S.at(i) == 'T') {
				S.at(i) = 'U';
			}
			else if (S.at(i) == 'U') {
				S.at(i) = 'V';
			}
			else if (S.at(i) == 'V') {
				S.at(i) = 'W';
			}
			else if (S.at(i) == 'W') {
				S.at(i) = 'X';
			}
			else if (S.at(i) == 'X') {
				S.at(i) = 'Y';
			}
			else if (S.at(i) == 'Y') {
				S.at(i) = 'Z';
			}
			else if (S.at(i) == 'Z') {
				S.at(i) = 'A';
			}
		}
	}
	for (int i1 = 0; i1 < S.size(); i1++) {
		cout << S.at(i1) ;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define base_max 32
#define pow_max 10
using namespace std;

int main()
{
  int x;
  cin >> x;
  
  int ans = 0;
  for(int b = 1; b < base_max; ++b)
  {
    for(int p = 2; p < pow_max; ++p)
    {
      int tmp = pow(b, p);
      if(tmp == x)
      {
        cout << tmp << endl;
        return 0;
      }
      ans = (tmp < x ? max(ans, tmp) : ans);
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

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;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] <= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) left = mid;
		else right = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return left;
}
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;
}

int main() {
	long long int n, m;
	long long int k;
	cin >> n >> m >> k;
	vector<long long int >av;
	vector<long long int >bv;
	for (int i = 0; i < n; i++) {
		long long int a;
		cin >> a;
		av.push_back(a);
	}
	long long int sum = 0;
	for (int i = 0; i < m; i++) {
		long long int b;
		cin >> b;
		bv.push_back(b);
		meguru.push_back(b + sum);
		sum = b + sum;
	}
	long long int time = k;
	int ans = 0;
	ans = max(ans, binary_search(k)+1);
	for (int i = 0; i < n; i++) {
		time = time - av[i];
		if (time < 0) {
			break;
		}
		int mn = binary_search(time);
		ans = max(ans, i + 1 + mn+1);
		//cout << i << " " << i + 1 + mn + 1 << " " << time <<" "<<mn<< endl;
	}
	cout << ans;
}

Measured memory_bytes: 9820
#include<bits/stdc++.h>
using namespace std;
int n,m;
char e[55][55];
bool check(int x,int y)
{
	int flag=0;
	if(x-1>=0&&e[x-1][y]=='.') flag++;
	if(x+1<n&&e[x+1][y]=='.') flag++;
	if(y-1>=0&&e[x][y-1]=='.') flag++;
	if(y+1<n&&e[x][y+1]=='.') flag++;
	if(flag==4) return false;
	return true;
}
int main()
{
	cin>>n>>m; 
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			cin>>e[i][j];
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
		{
			if(e[i][j]=='#')
				if(!check(i,j))
				{
					cout<<"No";
					return 0;
				} 
		}
	cout<<"Yes";
    return 0;
}


Measured memory_bytes: 256
n, m, l = [int(i) for i in input().split()]

A = []
for i in range(n):
    A.append([int(i) for i in input().split()])

B = []
for i in range(m):
    B.append([int(i) for i in input().split()])

C = [[0] * l for i in range(n)]

for i in range(n):
    for j in range(l):
        C[i][j] = sum(A[i][k] * B[k][j] for k in range(m))

for i in range(n):
    print(*C[i])

Measured memory_bytes: 9084
#include <stdio.h>

#define N 100


int main(){

  int n, i, j, A[N];
  int mini, swap, count=0;

  scanf("%d",&n);

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


  for(i=0;i<n-1;i++){

    mini = i;

    for(j=i+1;j<n;j++)
      if(A[mini]>A[j]) mini = j;

    if(mini != i){
	swap = A[i];
	A[i] = A[mini];
	A[mini] = swap;
	count++;
    }


  }

  printf("%d",A[0]);
  for(i=1;i<n;i++) 
    printf(" %d",A[i]);
  
  printf("\n%d\n", count);

  return 0;

}

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

using namespace std;

int main(){
	string a, b;
	char ope;
	cin >> a >> ope >> b;
	if(ope == '+'){
		cout << stoi(a) + stoi(b) << endl;
	}else{
		cout << stoi(a) - stoi(b) << endl;
	}
}


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

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

   vector<int> a(m);
   vector<int> b(m);
   rep(i,m) cin >> a[i] >> b[i];

   int c[n];
   rep(i,n) c[i] = 0;

   rep(i,m){
       c[a[i] - 1]++;
       c[b[i] - 1]++;
   }
   rep(i,n)print(c[i]);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define MAXN 100005
#define MAXA 1000000005
#define pb push_back
#define INF 999999999999999LL
using namespace std;
ll n,ar[MAXN],ar1[MAXN],art[MAXN],ans,bl,br,bm,ba,st[7*MAXN],l[7*MAXN],r[7*MAXN],stx,sta;
void buil(ll i){
    if (l[i]==r[i]) return;
 
    l[i*2]=l[i]; r[i*2]=l[i]+(r[i]-l[i])/2;
    l[i*2+1]=r[i*2]+1; r[i*2+1]=r[i];
 
    buil(i*2); buil(i*2+1);
}
void add(ll i){
    st[i]++;
 
    if (l[i]==r[i]) return;
 
    if (stx<=r[i*2]) add(i*2); else add(i*2+1);
}
void ret(ll i){
    if (stx<l[i]) return;
 
    if (r[i]<=stx) { sta+=st[i]; return; }
 
    ret(i*2); ret(i*2+1);
}
int main(){
    cin>>n;
    for (int i=1; i<=n; i++) scanf("%lld",&ar[i]);
 
    l[1]=-n-3; r[1]=n+3;
    buil(1);
 
    bl=1; br=MAXA;
    while(bl<=br){
        bm=(bl+br)/2;
        
        sta=stx=0; add(1);
 
        for (int i=1; i<=n; i++){
            if (ar[i]<bm) ar1[i]=-1;
            else ar1[i]=1;
 
            if (i) ar1[i]+=ar1[i-1];
 
            stx=ar1[i]; ret(1); add(1);
        }
 
        for (int i=0; i<7*MAXN; i++) st[i]=0;
        
        // cout<<bm<<" - "<<sta<<endl;
 
        if (2LL*sta>=n*(n+1LL)/2LL){
            ans=bm;
            bl=bm+1;
        }
        else br=bm-1;
    }
 
    cout<<ans<<endl;
}
/*
10
5 9 5 9 8 9 3 5 4 3
*/

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

int main() {
  int A,B,count;
  count = 0;
  cin >> A >> B;
  for(int i=A;i<=B;i++){
    if((i%10 == i/10000)&&((i/10)%10 == (i/1000)%10)){
      count += 1;
    }
  }
  cout << count <<endl;
}

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

#define Mset(s, n)      memset(s, n, sizeof(s))
#define Rp0(i, m)       for(int i = 0; i < m; ++i)
#define Rpd(i, m, l)    for(int i = l; i >= m; --i)
#define Rp1(i ,m)       for(int i = 1; i <= m; i++)
#define All(a)          (a).begin(), (a).end()
#define Lwb             lower_bound
#define Upb             upper_bound
#define Sz(a)           int((a).size())
#define u_map           unordered_map
#define fi              first
#define se              second
#define pb              push_back
#define pf              push_front
#define is              insert
#define ooi             INT_MAX
#define ool             LLONG_MAX
#define ll              long long
#define ull             unsigned ll
#define ld              long double
#define pii             pair<int, int>
#define vi              vector<int>
#define vpii            vector<pii>

const ll MOD = (ll) 1e9 + 7;
const ld PI = acos((ld) -1);
inline int Get_bit(int x, int k){return (x >> (k - 1)) & 1;}
inline ll Gcd(ll a, ll b) {ll r; while(b){ r = a % b; a = b; b = r;} return a;}
inline ll Lcm(ll a, ll b) {return a / Gcd(a, b) * b;}
inline ll Pow(ll n, ll k) {ll r = 1; for(; k; k >>= 1, n = n * n % MOD){if(k & 1) r = r * n % MOD;} return r;}
const int base = 311;


const int N = 1e6 + 10;

/*
    @ Copyright belong to Shadow4207
*/

ll n, m, k, ans, a[22][22];

void Solve(){
    cin >> n >> m;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            cin >> a[i][j];
        }
    }
    for(int i = 1; i < n; i++){
        for(int j = i + 1; j <= n; j++){
            int res = 0;
            for(int k = 1; k <= m; k++){
                res += (a[i][k] - a[j][k]) * (a[i][k] - a[j][k]);
            }
            if(res == int(sqrt(res)) * sqrt(res)) ans ++;
        }
    }
    cout << ans;
}


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
    Solve();
    return 0;
}











Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
from fractions import gcd
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

from itertools import permutations
from math import factorial, hypot

#############
# Main Code #
#############

N = getN()
if N == 1:
    print(0)
    exit()

def factime(ny):
    cnt = 1
    sum = 0
    while True:
        if sum + cnt > ny:
            break
        sum += cnt
        cnt += 1
    return cnt - 1

def prime_factorize(n):
    divisors = []
    # 27(2 * 2 * 7)の7を出すためにtemp使う
    temp = n
    for i in range(2, int(math.sqrt(n)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                # 素因数を見つけるたびにtempを割っていく
                temp //= i
            divisors.append([i, cnt])
    if temp != 1:
        divisors.append([temp, 1])
    if divisors == []:
        divisors.append([n, 1])

    return divisors

ans = 0
for i in prime_factorize(N):
    ans += factime(i[1])
print(ans)

Measured memory_bytes: 72808
#include <iostream>
#include <map>
#include <cstring>
using namespace std;
int main(){
	int n, s[12] = {0};
	while(cin >> n,n){
	for(int i = 0;i < n;i++){
		cin >> s[i];
	}

	int turn = 0;
	for(int i=10;i;i--){
		turn++;
		map<int,int> m;
		for(int i = 0;i < n;i++){
			m[s[i]]++;
		}//ツ古つ青板チツェツッツク
		int c[12];
		
		for(int i = 0;i < n;i++){
			c[i] = m[s[i]];
		}
		int j = 0;
		for(int i = 0;i < n;i++){
			j += (s[i] == c[i]);
		}

		if(j == n){
			cout << turn - 1 << endl;
			cout << s[0];
			for(int i = 1;i < n;i++){
				cout << " " << s[i];
			}
			cout << endl;
			break;
		}
		memcpy(s,c,sizeof(s));
	}
	}
}

Measured memory_bytes: 0
#include<stdio.h>
int main(void)
{
	int a,b;
	scanf("%d%d",&a,&b);
	if(a+b > 24) printf("%d",a+b-24);
  	else if(a+b == 24) printf("%d",0);
	else printf("%d",a+b);
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int N, A, B;
  int ans = 0;
  string s;

  cin >> N >> A >> B;


  
  
  cout << min(N*A, B) << endl;;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define degreeToRadian(deg) (((deg)/360)*2*M_PI)
#define radianTodegree(rad) (((rad)/2/M_PI)*360)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const int MOD = 1e9 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//cin.tie(0);ios::sync_with_stdio(false);
//cout << fixed << setprecision(15) << y << endl;
int main() {
  ll n;
  cin >> n;

  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  
  ll a = 1;
  ll l = n - 1;
  ll s = (n - 1) * (a + l) / 2;
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 3616
N = gets.to_i
as = gets.split.map(&:to_i)

two_count = 0
four_count = 0
as.each do |a|
  if a % 4 == 0
    four_count += 1
  elsif a % 2 == 0
    two_count += 1
  end
end
n = two_count
m = if two_count > 0
  four_count * 2
else
  four_count > 0 ? four_count * 2 + 1 : 0
end
puts(n + m >= N ? 'Yes' : 'No')


Measured memory_bytes: 8452
import collections
n = int(input())
a = list(map(int,input().split()))
a = collections.Counter(a)
a = list(a.items())
a.sort(reverse=True)
e1 = 0
e2 = 0
for i in range(len(a)):
    if a[i][1] >= 4 and e1 == 0:
        e1 = e2 = a[i][0]
        break
    elif a[i][1] >= 2:
        if e1 == 0:
            e1 = a[i][0]
        else:
            e2 = a[i][0]
            break
print(e1*e2)




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

int main() {
  int64_t n;
  cin >> n;
  int64_t m=n*(n+1)/2;
  m-=(n/3)*(n/3+1)/2*3+(n/5)*(n/5+1)/2*5-(n/15)*(n/15+1)/2*15 ;
  cout << m << endl;  
}


Measured memory_bytes: 3636
/*
 *
 *   Author     : Amit Kumar
 *   Date    	: June 11 2019
 * 
 */

#include <bits/stdc++.h>

#define FAST_INPUT_OUTPUT
//#define MORE_THAN_ONE_TESTCASE // COMMENT IT

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define umii unordered_map<int,int>
#define umll unordered_map<long long ,long long>
#define umsi unordered_map<string , int>
#define umsl map<string , long long> 
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define pqi priority_queue<int>
#define pql priority_queue<long long>
#define ub upper_bound
#define lb lower_bound
#define bint long long int
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define iv(v) for(auto &i:v){cin>>i;}
#define ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define ovn(v) for(auto i:v){cout<<i<<endl;}
#define euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define eovn(v) for(auto i:v){cerr<<i<<endl;}
#define os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define osn(s) for(auto itr:s){cout<<itr<<endl;}
#define eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define rep(x) for(auto i=0 ; i<(x); ++i)
#define _rep(a,b) for(auto i=(a); i<(b); ++i)
#define ef else if
#define wh while
#define el else
#define ivv(x) int x; cin>>x
#define lv(x) bint x; cin>>x
#define sv(x) string x; cin>>x
#define cv(x) char x; cin>>x
#define fv(x) float x; cin>>x
#define dv(x) double x; cin>>x
#define endl '\n'
using namespace std;




auto SOLUTION_FUNCTION( void ) ->void {

    // your solution goes here 

    ivv(n);
    ivv(m);

    vi x(m);

    iv(x);

    if(x.size()==1){
        cout<<0<<endl;
        return ;
    }

    sort(all(x));

    vi diff(m-1);

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

    sort(all(diff));

    int sum=0;

    for(int i=0; i<(m-n);++i){
        sum+=diff[i];
    }
    cout<<sum<<endl;

    return ;
}




int main(void){
#ifdef FAST_INPUT_OUTPUT
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#endif
#ifdef MY_LOCAL_PROJECT
    freopen("input","r",stdin);
    freopen("output","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}

Measured memory_bytes: 1024
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::collections::HashMap;
use std::cmp::{max,min};
fn main(){
    input!{
        n:usize,
        an:[i64;n],
    }
    let ans = solver(n,&an);
    for i in 0..n-1 {
        print!("{} ",ans[i]);
    }
    println!("{}",ans[n-1]);
}


fn solver(n:usize,an:&Vec<i64>) -> Vec<i64> {
    let sum = an.iter().sum();
    let mut x1 = sum; 
    for i in 1..(n-1) {
        if i % 2 != 0 {
            x1 -= 2 * an[i];
        }
    }
    let mut ans = vec![0;n];
    ans[0] = x1;
    for i in 0..(n-1) {
        ans[i+1] = 2 * an[i] - ans[i];
    }
    ans
}

fn is_prime(x:i64) -> bool {
    if x == 2 {return true;}
    if x < 2 || x % 2 == 0 {return false;}
    let mut j = 3;
    while j <= (x as f64).sqrt() as i64 {
        if x % j == 0 {
            return false;
        }
        j += 2;
    }
    true
}
#[test]
fn test_solver_1() {
    let n = 3;
    let an:Vec<i64> = vec![2,2,4];
    let res = solver(n,&an);
    assert_eq!(res,vec![4,0,4]);
}
#[test]
fn test_solver_2() {
    let n = 5;
    let an:Vec<i64> = vec![3,8,7,5,5];
    let res = solver(n,&an);
    assert_eq!(res,vec![2,4,12,2,8]);
}




Measured memory_bytes: 7420
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int k, n, ans = INT_LEAST32_MAX;
  cin >> n >> k;
  vector<int> dist;
  for (size_t i = 0; i < k; i++)
  {
    int tmp;
    cin >> tmp;
    dist.emplace_back(tmp);
  }
  for (size_t i = 0; i < k; i++)
  {
    auto hoge = dist[(k - 1 + i) % k] - dist[i];
    // cout << hoge << "(" << (k - 1 + i) % k << "," << i <<")"<< endl;
    if (hoge <= 0)
    {
      hoge += n;
    }
    if (hoge < ans)
    {
      ans = hoge;
    }
    hoge = n + dist[i] - dist[(i + 1) % k];
    if (hoge <= 0)
    {
      hoge += n;
    }
    if (hoge < ans)
    {
      ans = hoge;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1528