akhauriyash/Code-Regression huggingface dataset:
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#define test ll t; cin>>t; while(t--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 3005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<1000007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
/*int inv[1000001]={0};
void findinverse(){inv[1] = 1;for(int i = 2; i <=1e6 ; ++i)	inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;}
*/
using namespace std;
int n;
int a[MAX]={0};
int dp[MAX][MAX];
bool vis[MAX][MAX];
int solve(int i,int j){
	if(vis[i][j])	return dp[i][j];
	vis[i][j]=true;
	if(i==j)		return dp[i][j]=a[i];
	return dp[i][j]=max(a[i]-solve(i+1,j),a[j]-solve(i,j-1));
}
signed main(){
	fastio;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=0;i<MAX;i++){
		for(int j=0;j<MAX;j++){
			vis[i][j]=false;
		}
	}
	solve(1,n);
	cout<<dp[1][n]<<endl;
}


Measured memory_bytes: 58768
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  cin>>str;
  
  int sum=0;
  for(int i=0;i<(int)str.size();i++){
    if(str[i]=='o'){
      	sum++;
    }
  }
  sum+=15-str.size();
  if(sum>=8){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
  return(0);
}


Measured memory_bytes: 384
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	int n;
	int i;
	while(n=in()){
		for(i=0;i<9;i++){
			n-=in();
		}
		cout<<n<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	    
		String x = "";
		String ins = "";
		try {
			x = in.readLine();
			String[] num = x.split(" ");
			Dice d = new Dice (num);

			ins = in.readLine();
			for (int i = 0; i < ins.length(); i++) {
				d.move(ins.charAt(i));
			}
			System.out.println(d.getTop());
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}

class Dice {
	private int t, b, n, s, e, w;
	
	public Dice(String[] num) {
		t = Integer.parseInt(num[0]);
		s = Integer.parseInt(num[1]);
		e = Integer.parseInt(num[2]);
		w = Integer.parseInt(num[3]);
		n = Integer.parseInt(num[4]);
		b = Integer.parseInt(num[5]);
	}
	
	public void move(char c) {
		int tmp = 0;
		
		switch (c) {
		case 'N' :
			tmp = t;
			t = s;
			s = b;
			b = n;
			n = tmp;
			break;
		case 'S' :
			tmp = t;
			t = n;
			n = b;
			b = s;
			s = tmp;
			break;
		case 'E' :
			tmp = t;
			t = w;
			w = b;
			b = e;
			e = tmp;
			break;
		case 'W' :
			tmp = t;
			t = e;
			e = b;
			b = w;
			w = tmp;
			break;
		}
	}
	
	public int getTop() {
		return t;
	}
}

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

struct edge{int to,dist;};
using Graph  = vector<vector<edge>>;
#define INF 1e9

int main(){
    int V,E;
    cin >> V >> E;  

    Graph G(V);
    for(int i = 0;i < E;i++){
        int s,t,d;
        cin >> s >> t >> d;
        G[s].push_back({t,d});
    }

    vector<vector<int>> dp(1 << V, vector<int>(V,INF));
    dp[0][0] = 0;

    for(int bit = 0;bit < (1 << V);bit++){
        for(int nowV = 0; nowV < V;nowV++){
            if(dp[bit][nowV] == INF) continue;
            for(auto e : G[nowV]){
                if((bit >> e.to) & 1) continue;
                int nbit = bit | (1 << e.to);
                dp[nbit][e.to] = min(dp[nbit][e.to], dp[bit][nowV] + e.dist);
            }
        }
    }
    cout << (dp[(1 << V) -1][0] == INF ? -1 : dp[(1 << V) -1][0]) << endl;
}



Measured memory_bytes: 6332
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())
 
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18


int main() {
    int a;
    string s;
    cin>>a >> s;
    if(a>=3200){ cout << s << endl;}
    else{cout << "red" << endl;}
}

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

int n, q, head, last;
int pre[100005] = {0};
int suf[100005] = {0};

void solve(int x);

int main() {
  int bf;
  cin >> n >> q;
  if(n == 1) {
    cout << 1 << endl;
    return 0;
  }
  for(int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    if(i == 0) {
      head = x;
      pre[x] = -1;
    }
    else {
      if(i == n - 1) {
        last = x;
        suf[x] = -1;
      }
      pre[x] = bf;
      suf[bf] = x;
    }
    bf = x;
  }
  for(int i = 0; i < q; ++i) {
    int x;
    cin >> x;
    solve(x);
  }
  while(head != -1) {
    cout << head;
    if(suf[head] != -1) cout << " ";
    head = suf[head];
  }
  cout << endl;
  return 0;
}
void solve(int x) {
  if(x == head) {
    head = suf[x];
    suf[last] = x;
    suf[x] = -1;
    pre[head] = -1;
    pre[x] = last;
    last = x;
    return;
  }
  if(x == last) {
    last = pre[x];
    pre[head] = x;
    pre[x] = -1;
    suf[last] = -1;
    suf[x] = head;
    head = x;
    return;
  }
  int nhead = suf[x], nlast = pre[x];
  pre[nhead] = -1;
  suf[nlast] = -1;
  suf[x] = head;
  pre[x] = last;
  suf[last] = x;
  pre[head] = x;
  head = nhead;
  last = nlast;
}


Measured memory_bytes: 3860
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,pair<int,int> > pipii;
typedef priority_queue<pii,vector<pii>,greater<pii>> minpq;
typedef priority_queue<pii> maxpq;
//const double PI = acos(-1);
const int mod = 1000000007;
int cnt =0;

void show_vect(vector<int>v){
    tr(it,v){
        cout<<*it<<" ";
    }
    cout<<endl;
}
bool isPowerOfTwo (int x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
} 
void printString(int n) 
{ 
	int arr[10000]; 
	int i = 0; 

	// Step 1: Converting to number assuming 
	// 0 in number system 
	while (n) { 
		arr[i] = n % 26; 
		n = n / 26; 
		i++; 
	} 

	// Step 2: Getting rid of 0, as 0 is 
	// not part of number system 
	for (int j = 0; j < i - 1; j++) { 
		if (arr[j] <= 0) { 
			arr[j] += 26; 
			arr[j + 1] = arr[j + 1] - 1; 
		} 
	} 

	for (int j = i; j >= 0; j--) { 
		if (arr[j] > 0) 
			cout << char('a' + arr[j] - 1); 
	} 

	cout << endl; 
} 


int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    printString(n);



   


       
        







  


    
    
}

Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main()
{
	char grid[3][3];
	for (int i = 0; i < 3; i++)
		for (int j = 0; j < 3; j++)
			cin >> grid[i][j];
	for (int i = 0; i < 3; i++)
		cout << grid[i][i];
	cout << endl;
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> ii;

const int N = 55;
int h, w;
string a[N];
const vector<ii> dxy = {{1,0},{-1,0},{0,1},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1}};
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> h >> w;
    for (int i = 0; i < h; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (a[i][j] == '.') {
                int Cnt = 0;
                for (auto [dx, dy] : dxy) {
                    int nx = i + dx;
                    int ny = j + dy;
                    if (nx < 0 || ny < 0 || nx == h || ny == w) continue;
                    if (a[nx][ny] == '#')
                        ++Cnt;
                }
                a[i][j] = '0' + Cnt;
            }
        }
    }
    for (int i = 0; i < h; ++i) {
        cout << a[i] << endl;
    }

    return 0;
}



Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
 
using namespace std;
 
const ll MOD = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int N;
    cin >> N;
    vector<ll> A(N),B(N),C(N);
    rep(i,N)cin >> A[i];
    B[0] = A[0];
    C[N-1] = A[N-1];
    rep(i,N)if(i-1>=0)B[i] = __gcd(B[i-1],A[i]);
    for(int i=N-1;i>=0;i--){
        if(i+1<N)C[i] = __gcd(C[i+1],A[i]);
    }
    ll ans = max(B[N-2],C[1]);
    rep(i,N){
        if(i-1>=0&&i+1<N){
            ans = max(ans,__gcd(B[i-1],C[i+1]));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
<?php
  fscanf(STDIN,"%d %d %d",$n,$m,$x);
  
  function getCpattern( $source, $m ){
 /* 引数 $source：選択元要素の配列 */
 /* 引数 $m：$source から異なる $m 個を選ぶ */

 $n = sizeof($source);

 return ptn( $source, $n, array(), 0, $n-$m+1 );

}

/* ptn：内部で再帰的に呼び出される関数 */
function ptn( $source, $n, $subset, $begin, $end ){
 $p = array();
 for( $i = $begin; $i<$end; $i++){
  $tmp =array_merge( $subset, (array)$source[$i] );
  if( $end+1 <= $n ){
   $p = array_merge($p , ptn( $source, $n, $tmp, $i+1, $end+1 ) );
  }else{
   array_push( $p, $tmp );
  }
 }
 return $p;
}
  
  $source = range(1,$n);
  $kumi = [];
  for($i=1; $i<=$n; $i++){
    if($i == 1){
        $kumi = getCPattern( $source, $i );
    }else{
        $kumi = array_merge($kumi,getCPattern( $source, $i )); 
    }
    
  }

//   print_r( $kumi );//結果を表示
  
  
  
  
  $ca = [];
  for($i=1; $i<=$n; $i++){
      $ca[$i] = explode(" ",trim(fgets(STDIN)));
  }
//   print_r($ca);


//   print_r($skill);
  $money = 99999999999;
  $skill_def = array_fill(1, $m, 0);
  for($i=0; $i<count($kumi); $i++){
      $skill = $skill_def;
      $m = 0;
      for($j=0; $j<count($kumi[$i]); $j++){
          foreach ($ca[$kumi[$i][$j]] as $key => $data){
              if($key > 0){
                  $skill[$key] += $data;
              }else{
                  $m += $data;
              }
          }
      }
      rsort($skill);
    //   print_r($skill);
      for($k=0; $k<count($skill); $k++){
          if($skill[$k] >= $x){
              $flag = true;
          }else{
              $flag = false;
          }
      }
      if($flag){
          $money = min($money,$m);
      }
  }
  
  if($money != 99999999999){
    echo $money."\n";
  }else{
      echo "-1\n";
  }


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

int top, S[1000];

void push(int x) {
/* top?????????????????????????????????????????\ */
	S[++top] = x;
}

int pop() {
	top--;
/* top??????????????????????´?????????? */
	return S[top+1];
}

int main() {
	int a, b;
	top = 0;
	char s[100];
	
	while( scanf("%s", s) != EOF) {
		if ( s[0] == '+' ) {
			a = pop();
			b = pop();
			push(a + b);
		} else if ( s[0] == '-' ) {
			b = pop();
			a = pop();
			push(a - b);
		} else if ( s[0] == '*' ) {
			a = pop();
			b = pop();
			push(a * b);
		} else {
			push(atoi(s));
		}
	}
	
	printf("%d\n", pop());
	
	return 0;
}
	

Measured memory_bytes: 548
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int p[n];
  for(int i=0;i<n;i++)cin>>p[i];
  int c=0;
  for(int i=1;i<n-1;i++){
    if((p[i]-p[i-1])*(p[i+1]-p[i])>0){c++;}
  }
  cout<<c<<endl;
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main() {

    ll N;
    cin >> N;

    map<ll, ll> mp;

    for(ll i = 0; i < N; i++){
        ll t; cin >> t;
        mp[t]++;
    }

    if(mp.size() == N){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }



}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std; 
#define int int64_t
#define itn int
#define fi first
#define se second 
signed main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,ans=1000;
  int a[100];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=1;i<n;i++){
    if(a[i-1]<a[i]){
      ans=(ans/a[i-1])*a[i]+(ans%a[i-1]);
    }
  }
  cout<<ans<<"\n";
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace  std;

#define ll long long
#define ull unsigned long long
#define f first
#define s second
typedef pair<int , int > pii;
typedef pair<ll,ll> pll;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
// erase,insert same as normal set

const ll MOD = 1e9+7;

void min_self(ll &a , ll b){a=min(a,b);}
void max_self(ll &a, ll b){a=max(a,b);}
ll add(ll x, ll y){return (x + y) % MOD;}
ll sub(ll x, ll y){return add(x, MOD - y);}
ll mul(ll x, ll y){return (x * 1ll * y) % MOD;}
ll binpow(ll x, ll y)
{   ll z = 1;
    while(y > 0)
    {if(y % 2 == 1) z = mul(z, x);
        x = mul(x, x);
        y /= 2;
    }
    return z;
}
ll inv(ll x){return binpow(x, MOD - 2);}
const int MXN = 1e6+10;
ll fact[MXN];
void fac_pre()
{
    fact[0]=1;
    for(ll i=1; i<MXN; i++){
        fact[i]=mul(fact[i-1],i);
    }
}
ll C(ll n, ll k)
{
    return mul(fact[n], inv(mul(fact[k], fact[n - k])));
}

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}
///--//

int  main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen ("output.txt","w",stdout);
    /* KEEP IN MIND
     * take care when sorting a 1 based indexed vector
     * use greater<ll> for ll's
    */
    int h,w; cin>>h>>w;
    vector<int> in_row(h+1,0);
    vector<int> in_col(w+1,0);
    int m; cin>>m;
    vector<pii> points;
    for(int i=0; i<m; i++){
        int x,y; cin>>x>>y;
        in_row[x]++;
        in_col[y]++;
        points.push_back({x,y});
    }
    int mx_row=0,mx_col=0;
    for(int i=1; i<=h; i++){
        mx_row=max(mx_row,in_row[i]);
    }
    for(int i=1; i<=w; i++){
        mx_col=max(mx_col,in_col[i]);
    }
    ll cx=0;
    ll cy=0;
    for(int i=1 ; i<=h; i++){
        if(in_row[i] == mx_row) cx++;
    }
    for(int i=1 ; i<=w; i++){
        if(in_col[i] == mx_col) cy++;
    }
    ll cnt=cx*cy;
    for(auto p : points){
        int x=p.first,y=p.second;
        if(in_row[x] + in_col[y] == mx_row+mx_col) cnt--;
    }
    cout<<mx_row+mx_col-(cnt<=0);

}

Measured memory_bytes: 9748
#include<iostream>
#include<algorithm>
#include<vector>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int main(void) {
	int n, m;
	cin>>n>>m;
	vector<P> arm(m);
	REP(i, m) {
		cin>>arm[i].first>>arm[i].second;
		--arm[i].second;
	}
	sort(ALL(arm));
	vector<P> rng(n);
	REP(i, n) {
		rng[i].first = i;
		rng[i].second = i;
	}
	REP(i, m) {
		rng[arm[i].second].second = max(rng[arm[i].second].second, rng[arm[i].second + 1].second);
		rng[arm[i].second + 1].first = min(rng[arm[i].second + 1].first, rng[arm[i].second].first);
	}
	REP(i, n) {
		cout<<rng[i].second - rng[i].first + 1;
		if(i != n - 1) cout<<' ';
		else cout<<endl;
	}
}

Measured memory_bytes: 7596
#include <iostream>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <vector>
#include <queue>

using namespace std;

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

int main() {
  int k = 0;
  cin >> k;
  long long ans = 0;
  for(int i = 1; i <= k; i++) {
    for(int j = 1; j <= k; j++) {
      for(int m = 1; m <= k; m++) {
        int t = gcd(gcd(i, j), m);
        ans += t;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N, K; cin >> N >> K;

	int Kodd = 0;
	int Keven = 0;
	for (int i = 1; i <= N; ++i){
		if (i % K == 0){
			++Kodd;
		}else
		if (K % 2 == 0 && (i % K == K / 2)){
			++Keven;
		} // end if
	} // end for

	ll res = (ll)pow((ll)Kodd,3LL);
	if (K % 2 == 0){
		res += (ll)pow((ll)Keven, 3LL);
	} // end if
	
	cout << res << endl;
 
	return 0;
}

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  for (int i = 1; i < B; i++) {
    if ((A * i) % B == C) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}

Measured memory_bytes: 256
/*
.   Bismillahir Rahmanir Rahim
.   Author - Marajul islam
.   created- 

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


 
int sc1() {int x; scanf("%d", &x); return x;}
long long sc2() {long long x; scanf("%lld", &x); return x;}

const int mod= 1e9 + 7;
inline int add(int a, int b) {a += b; return a >= mod ? a - mod : a;}
inline int sub(int a, int b) {a -= b; return a < 0 ? a + mod : a;}
inline int mul(int a, int b) {return (long long)a * b % mod;}
 
#define F               first
#define S               second 
#define mp              make_pair
#define pb              push_back
#define pf              push_front
#define speed_up        ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x)           (int)x.size()
#define all(x)          x.begin(), x.end()
#define debug           cerr << "OK\n";
#define ub              upper_bound
#define lb              lower_bound
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        (a*b)/gcd(a,b)
#define Int             sc1()
#define LL              sc2()
#define For(n)          for(int i=0;i<n;i++)
#define Forj(n)         for(int j=0;j<n;j++)
#define Fork(n)         for(int k=0;k<n;k++)
#define For1(n)         for(int i=1;i<=n;i++)

typedef long long       ll;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef set <int>       si;
typedef set <ll>        sll;
typedef multiset <int>  msi;
typedef multiset <ll>   msll;
typedef map <int, int>  mi;
typedef map <ll, ll>    mll;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ", ";
    err(++it, args...);
}
  
const int inf           = (int)2e9 + 5;
const ll  Inf           = (ll)1e18 + 5;
const int N             = 5e6 + 5;
 
 
 
int solve() {
 
	int n=Int;
	ll sum=0;
	for(int i=1;i<=n;i++){
		if(i%3==0 || i%5==0){}
		else sum+=(ll) i;
	}
	cout<<sum<<endl;
 
	return 0;
}
 
 
 
 
int main()
{
	//speed_up;
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
 
	int test = 1, tc = 0;
	//scanf("%d", &test);
	//cin >> test;
	while (test--) {
		//printf("Case %d: ", ++tc);
		solve();
	}
 
	return 0;
 
 
 
 
}




Measured memory_bytes: 3660
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vi A(n);
  ll cnt=0;
  ll ans=0;
  for(auto &a:A){cin>>a;cnt+=(a==0);}
  while(cnt!=n){
    for(int i=0;i<n;i++){
      ll cncn=0;
      while(A[i]!=0){
	A[i]--;
	if(A[i]==0)cnt++;
	i++;
	cncn++;
      }
      if(cncn!=0)ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n,x;
    cin >> n >> x;
    while(n != 0 || x != 0) {
    int ans = 0;
    for(int i = 1;i < n;i++) {
        for(int j = i + 1;j < n;j++) {
            if(x -(i + j) > j && x -(i + j) <= n) 
                ans++;
        }
    }
    cout << ans << endl;
    
    cin >> n >> x;
    }
}


Measured memory_bytes: 3096
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))


s = list(input())

ans = 0

for i in range(1<<len(s)-1):
    ttl = []
    memo = s[0]
    for j in range(0,len(s)-1):
        if (i>>j)&1:
            memo += s[j+1]
        else:
            ttl.append(int(memo))
            memo = s[j+1]
    ttl.append(int(memo))
    ans += sum(ttl)
    ttl = []

print(ans)




Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main()
{
    int N;
	cin >> N;
	vector<int> v; 
    int cnt = 0;
    int tmp;
	for (int i=0; i<N; i++)
	{
		cin >> tmp;
        v.push_back(tmp);
	}
    std::sort(v.begin(), v.end());
  	for (int i=0; i<N-2; i++)
	{
		for (int j=i+1; j<N-1; j++)
        {
        	for (int k=j+1; k<N; k++)
          	{
            	int a = v[i];
            	int b = v[j];
            	int c = v[k];
				if (c < a+b) {
  					cnt += 1;                    
                } else {
                    break;
                }
			}
        }
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main{

    void solve(){
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt(), B = sc.nextInt();
        int[] a = new int[A];
        int[] b = new int[B];
        for(int i=0; i<A; i++) a[i] = sc.nextInt();
        for(int i=0; i<B; i++) b[i] = sc.nextInt();

        int[][] aa = new int[1001][];
        for(int i=1; i<=1000; i++){
            int cnt = 0;
            for(int j=0; j<A; j++) 
                if(a[j]==i) cnt++;
            aa[i] = new int[cnt];
            int idx = 0;
            for(int j=0; j<A; j++)
                if(a[j]==i) aa[i][idx++] = j;
        }

        int max = 0;
        for(int start = 0; start < B; start++){
            int cnt = 0, pos = -1;
            for(int i=start; i<B; i++){
                int before = cnt;
                for(int j=0; j<aa[b[i]].length; j++){
                    if(aa[b[i]][j]>pos){
                        cnt++;
                        pos = aa[b[i]][j];
                        break;
                    }
                }
                if(before==cnt) break;
            }
            max = Math.max(max, cnt);
        }
        System.out.println(max);
    }

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

Measured memory_bytes: 37856
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
//#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


signed main(){
  int h,w;cin>>h>>w;
  rep(j,h){
    rep(i,w){
      string s;cin>>s;
      if(s=="snuke")cout << (char)('A'+i) << j+1 << endl;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <map>
#define ll long long
#define REP(i, x) for(int (i) = 0; (i) < (x); (i) ++)
#define pi 3.1415926535
const int MOD = 1000000007;
using namespace std;

int main() {
	int n, m;
	ll ans = 1;
	cin >> n >> m;
	if (abs(n - m) >= 2) {
		cout << 0 << endl;
	}
	else if (abs(n - m) == 1) {
		for (int i = n; i > 1; i--) {
			ans *= i;
			ans %= MOD;
		}
		for (int i = m; i > 1; i--) {
			ans *= i;
			ans %= MOD;
		}
		cout << ans << endl;
	}
	else {
		for (int i = n; i > 1; i--) {
			ans *= i;
			ans %= MOD;
		}
		for (int i = m; i > 1; i--) {
			ans *= i;
			ans %= MOD;
		}
		ans *= 2;
		ans %= MOD;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 764
# Template 1.0
import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n,a,b = MAP()

q = n//(a+b)
rem = n%(a+b)

ans = q*a
if(rem>a):
    print(ans + a)
else:
    print(ans + rem)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define st first
#define nd second

using namespace std;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(long long _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

const long long N = 100100;
long long n, a[N];
long long ans = 0;
priority_queue <pair<long long, long long> > pq;
set <long long> s;

int main() {
	ios_base::sync_with_stdio(false);

	cin >> n;
	for(long long i = 1; i <= n; i++) {
		cin >> a[i];
		pq.push({a[i], i});
	}

	s.insert(0);
	s.insert(n + 1);


	while(!pq.empty()) {
		long long x = pq.top().nd;
		pq.pop();


		auto it = s.upper_bound(x);
		auto it2 = prev(it);

		long long r1 = *it, r2 = *it;
		long long l1 = *it2, l2 = *it2;

		it++;
		if(it != s.end())
			r2 = *it;
		if(it2 != s.begin())	{
			it2--;
			l2 = *it2;
		}
		// dbg(x, l2, l1, r1, r2);
		// dbg(ans);
		ans += a[x] * (x - l1) * (r2 - r1);
		// dbg(ans);
		ans += a[x] * (r1 - x) * (l1 - l2);
		// dbg(ans);

		s.insert(x);
	}
	cout << ans << '\n';
}	

	

Measured memory_bytes: 7280
N,M = map(int,input().split())
S = list(map(int,input().split()))
T = list(map(int,input().split()))

MOD = 10**9+7

a = [[0 for j in range(M+1)] for i in range(N+1)]

for i in range(N+1) :
    for j in range(M+1) :
        if i == 0 or j == 0 :
            a[i][j] = 1
        else :
            a[i][j] = a[i-1][j] + a[i][j-1] - (a[i-1][j-1] if S[i-1] != T[j-1] else 0)
            a[i][j] %= MOD

print(a[N][M])


Measured memory_bytes: 74204
#include<bits/stdc++.h>
using namespace std;
struct node{
long long d,g;
bool operator<(const node &w)
{
	if(d!=w.d)
		return d<w.d;
}
};
bool func(node k,int n)
{
if(k.d<=n)
	return false;
else return true;
}
int main()
{
int n,d;cin>>n>>d;
int points[n][d];
for(int i=0;i<n;i++)
	for(int j=0;j<d;j++)
		cin>>points[i][j];
int total=0;
for(int i=0;i<n;i++)
	for(int j=i+1;j<n;j++)
{
double sum=0;
for(int k=0;k<d;k++)
	sum+=(points[i][k]-points[j][k])*(points[i][k]-points[j][k]);
double d=sqrt(sum);
if(floor(d)==ceil(d))
	total++;


}
cout<<total;

return 0;
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline

# input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


def calc_next(N, S):
    dp = [[0 for i in range(26)] for i in range(N+1)]

    for i in range(N-1, -1, -1):
        for j in range(26):
            dp[i][j] = dp[i+1][j]
        dp[i][ord(S[i])-ord('a')] = i

    return dp


def main():
    N = int(input())
    S = input()
    a = [0 for i in range(26)]
    ans = 1

    for i in range(N):
        a[ord(S[i])-ord('a')] += 1

    for i in range(26):
        ans *= a[i] + 1
        ans %= MOD

    print(ans - 1)


if __name__ == '__main__':
    main()


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

int main() {
  int W, H, N;
  cin >> W >> H >> N;
  
  int s = 0, t = 0;
  for (int i = 0; i < N; i++) {
    int x, y, a;
    cin >> x >> y >> a;

    if (a == 1) s = max(s, x);
    if (a == 2) W = min(W, x);
    if (a == 3) t = max(t, y);
    if (a == 4) H = min(H, y);
  }

  if (W <= s || H <= t) cout << 0 << endl;
  else cout << (W - s) * (H - t) << endl;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
V=list(map(int,input().split()))
a=0
for i in range(0,K+1):
    li=V[:i]
    for j in range(0,K+1):
        if i+j>N or i+j>K:
            break
        if j:
            lj=li+V[-j:]
        else:
            lj=li
        for k in range(0,K+1):
            if i+j+k>K:
                break
            if i+j>=k:
                lj.sort()
                a=max(a,sum(lj[k:]))
print(a)

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

//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
//typedef unsigned long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
typedef pair<int, int> P;
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<string> &s, string a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;


int main() {
    int n;
    cin >> n;
    map<ll, int> a;
    rep(i, n) {
        ll d;
        cin >> d;
        a[d]++;
    }

    int m;
    cin >> m;
    rep(i, m) {
        ll t;
        cin >> t;
        a[t]--;
    }

    for (auto e : a) {
        if (e.second < 0) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;

}



Measured memory_bytes: 12800
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

vector<int> keta(int x) {
  vector<int> res;
  while(x) {
    res.push_back(x%10);
    x /= 10;
  }
  return res;
}

bool f(vector<int> a) {
  bool res = true;
  int n = a.size();
  rep(i ,n) {
    if(a[0] != a[i]) res = false;
  }
  return res;
}

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

  // int m = t.size();
  // rep(i, m) cout << t[i] << endl;
  // YORN(f(t));

  bool b = true;

  while(b) {
    vector<int> t = keta(i);
    if(f(t)) {
      cout << i << endl;
      return 0;
    } else {
      i++;
    }
  }
  return 0;
}

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

int main(void){
    int m = 10000;
    int i = 0;
    vector<int> A(m);
    while(1){
        cin >> A[i];
        if(A[i] == 0)   break;
        i++;
    }
    
    for (int k = 0; k < i; k++){
        cout << "Case " << k+1 << ": " << A[k] << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3136
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n,a,b;
    cin>>n>>a>>b;
    int p[n];
    for(int i=0;i<n;i++)cin>>p[i];
    ll x=0,y=0,z=0;
    for(int i=0;i<n;i++){
        if(a>=p[i])x++;
        else if(b>=p[i])y++;
        else z++;
    }
    cout << (min(x,min(y,z)))<<endl;
    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
s = []
e = []
for i in range(m):
    a, b = map(int, input().split())
    if a == 1:
        s.append(b)
    elif b == n:
        e.append(a)
if len(set(s) & set(e)) != 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Measured memory_bytes: 21864
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] d = new int[N];
		for(int i = 0;i < N;++i)
			d[i] = sc.nextInt();
		sc.close();
		
		Set<Integer> set = new HashSet<>();
		for(int i = 0;i < N;++i)
			set.add(d[i]);
		System.out.println(set.size());
	}
}


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

int N;

ll triangles(vector<ll> &L) {
    sort(L.begin(), L.end());
    ll sum = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            ll x = L[i] + L[j];
            auto itr = lower_bound(L.begin(), L.end(), x);
            sum += distance(L.begin() + j, itr) - 1;
        }
    }

    return sum;
}

int main() {
    cin >> N;
    vector<ll> L(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &L[i]);
    }

    ll ans = triangles(L);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 1e18;
const double INFD = 1e30;
const double PI = 3.14159265;
const ll MOD = 1e9 + 7;

template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}

const int MAXN = 505;
int n, m, k;
int CASE = 1;
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
int deg[MAXN];
int sum[MAXN];

struct Edge {
    int fr;
    int to;
    int dis;
    Edge() = default;
    Edge(int fr, int to, int dis) : fr(fr), to(to), dis(dis) {}
    bool operator<(const Edge& b) const { return this->dis < b.dis; }
};

int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    scanf("%d", &n);
    printf("%lf", n & 1 ? ((n / 2 + 1) / (double)n) : (n / 2) / (double)n);
    return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val k = scanner.nextInt()
    val s = scanner.nextInt()

    var sum = 0
    for (x in 0..k) {
        for (y in 0..k) {
            val z = s - x - y
            if (0 <= z && z <= k) {
                sum += 1
            }
        }
    }

    println(sum)
}

Measured memory_bytes: 31392
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const ll MOD = 1e9 + 7;
struct mint {
    ll x;
    mint() : x(0) {}
    mint(ll x) : x((x % MOD + MOD) % MOD) {}
    mint& operator+=(const mint& r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; }
    mint& operator-=(const mint& r) { if ((x -= r.x) < 0) { x += MOD; } return *this; }
    mint& operator*=(const mint& r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; }
    mint& operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; }
    mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x-= MOD; } return ret; }
    mint& operator--() { if ((--x) < 0) { x += MOD; } return *this; }
    mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; }
    mint operator+(const mint& r) { mint ret; return ret = x + r.x; }
    mint operator-(const mint& r) { mint ret; return ret = x - r.x; }
    mint operator*(const mint& r) { mint ret; return ret = x * r.x; }
    mint operator-() { return mint() - *this; }
    bool operator<(const mint& a) { return x < a.x; }
    bool operator>(const mint& a) { return x > a.x; }
    bool operator<=(const mint& a) { return x <= a.x; }
    bool operator>=(const mint& a) { return x >= a.x; }
    bool operator==(const mint& a) { return x == a.x; }
    bool operator!=(const mint& a) { return x != a.x; }
};
ostream& operator<<(ostream& os, const mint& r) { os << r.x; return os; }
ostream& operator>>(ostream& os, const mint& r) { os >> r.x; return os; }

void solve(istream& cin, ostream& cout) {
  int A, B, M;
  cin >> A >> B >> M;
  vector<int> a(A), b(B), x(M), y(M), z(M);
  REP(i, A) cin >> a[i];
  REP(j, B) cin >> b[j];
  REP(k, M) cin >> x[k] >> y[k] >> z[k];
  int a_min, b_min, sum_min, dis;

  a_min = *min_element(a.begin(), a.end());
  b_min = *min_element(b.begin(), b.end());
  sum_min = a_min + b_min;
  REP(i, M) {
    dis = a[x[i] - 1] + b[y[i] - 1] - z[i];
    if (sum_min > dis) sum_min = dis;
  }
  cout << sum_min << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


Measured memory_bytes: 2176
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <utility>
#include <cmath>
#include <string>
#include <bitset>
#include <queue>
#include <cstdio>
#include <cstring>
#include <deque>
#include <unordered_map>
#include <climits>
#include <map>
#include <iomanip>
#include <set>
#include <unordered_set>
#include <ctime>

#define ci(t) cin>>t
#define co(t) cout<<t
#define LL long long
#define fa(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>b;--i)
#define setp pair<pair<int,int>,int>
#define setl pair<int,int>

using namespace std;

int gcd(int a, int b) { return a % b ? gcd(b, a % b) : b; }
pair <int, int> vu[4] = { {0,1}, {0,-1} , {1,0},{-1,0} }; // EWSN

const int max_v = 1e5 + 7;
const int INF = 1e7 + 7;

int n,l;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	ci(n >> l);
	int sum = (n * (n - 1)) / 2 + n * l;
	int t = n + l-1;
	if (l > 0 && t > 0)
	{
		co(sum - min(l, t));
	}
	else if (l < 0 && t < 0)
	{
		co(sum - max(l, t));
	}
	else co(sum);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	int a, b;
	cin >> a >> b;
	cout << (a+b)%24 << endl;
 	return 0;
}

Measured memory_bytes: 256
# atcoder : python3 (3.4.3)
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
mod = 10**9+7

# main
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if 500*a + 100*b + 50*c == X:
                ans += 1

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(vec) vec.begin(), vec.end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = (1e9 + 7);
ll dp[100010];
ll gcd(ll x, ll y){
  return y == 0 ? x : gcd(y, x % y);
}
ll lcg(ll x, ll y){
  return x * y / gcd(x, y);
}
map<ll, ll> factor(ll n){
  map<ll, ll> ans;
  ll a = 2;
  while (n >= a * a){
    if (n % a == 0){
      ans[a]++;
      n /= a;
    }
    else a++;
  }
  ans[n]++;
  return ans;
}
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 s, b; cin >> s >> b;
  map<int, bool> isBroken;
  rep(i, s) isBroken[i] = false;
  rep(i, b){
    int x; cin >> x;
    isBroken[x] = true;
  }

  //string ans = "Yes";
  //string ans = "No";
  //string ans = "YES";
  //string ans = "NO";
  ll ans = 0;
  dp[0] = 1;
  for (int i = 1; i <= s; ++i){
    if (!isBroken[i]){
      dp[i] += dp[i - 1];
      if (i > 1) dp[i] += dp[i - 2];
      dp[i] %= MOD;
    }
  }
  ans = dp[s] % MOD;
  
  cout << ans << endl;
}

Measured memory_bytes: 5760
# include <bits/stdc++.h>
# define pb push_back
# define ll long long
# define fi first
# define se second
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define mkp make_pair
//# define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"

using namespace std;

ll q , w , e , z ;


int main()
{
	speed;

    int n ;
    cin >> n ;
    int s[n];
    for(int i = 0 ; i < n ; i ++ ){
        cin >> s[i] ;
    }
    for(int i = 1 ; i < n - 1 ; i ++ ){
        if((s[i]>=s[i-1] && s[i]<s[i+1]) || ( s[i]<s[i-1] && s[i]>=s[i+1])){
            z++;
        }
    }
    cout<<z;


	time;
}


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

int main(){
    int N,K;
    cin >> N >> K;
    int A;
    vector<int> B(N+1,0);
    for (int i=0;i<N;++i) {
        cin >> A;
        B[A]++;
    }
    sort(B.begin(),B.end(),greater<int>());
    int tmp =0;
    for(int i=K;i<=N;++i) {
        tmp += B[i];
    }
    
    cout << tmp << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<ctime>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define int long long
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
    int x = 0; char ch = gc(); bool positive = 1;
    for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
    for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
    return positive ? x : -x;
}
inline void write(int a){
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
    }
    write(a); puts("");
}
ll n,ans;
ll solve(ll a,ll b){return a%b?solve(a*(b-1)/b,b):a/b;}
ll Dec(ll a,ll b){return a-a*(b-1)/b;}
ll Solve(ll a,ll b){
	for(;a%b;){
		ll l=1,r=1e9,ans=0,dec=Dec(a,b);
		for(;l<=r;){
			ll mid=(l+r)>>1;
			if (a-mid*dec>=0&&Dec(a-mid*dec,b)==dec){ans=mid; l=mid+1;}
			else r=mid-1;
		}
		a-=dec*(ans+1);
	}
	return a/b;
}
signed main(){
	n=read();
	for(int i=1;i<=n;i++){ll x=read(),y=read();ans^=Solve(x,y);}
	puts(ans?"Takahashi":"Aoki");
}

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

int main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int table[4] = {25,10,5,1},index = 0,num = 0;
    unsigned long input;
    cin >> input;
    
    while(1){
        if(input >= table[index]){
            int tmp = input / table[index];
            num += tmp;
            input -= tmp * table[index];
            if(input <= 0){
                break;
            }
        }
        ++index;
    }
    cout << num << endl;
}


Measured memory_bytes: 3208