akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, __VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

#define MOD 1000000007
#define INF 1000000000
#define MAX_N 100010

int N, Y;

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

    for(int i = 0; i <= N; ++i) {
        for(int j = 0; j <= N - i; ++j) {
            int k = N - i - j;
            if(i * 10000 + j * 5000 + k * 1000 == Y) {
                printf("%d %d %d\n", i, j, k);
                return 0;
            }
        }
    }
    printf("-1 -1 -1\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int main()
{
	int n,h,w;
	cin >> n >> h >> w;
	cout << (n-h+1)*(n-w+1) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    long N,M;
  	vector<long> v;
  
  	cin >> N >> M;
  
  	for(long i = 0; i < M; i++){
      int A;
      cin >> A;
      v.push_back(A);
      
    } 	
  
  long Sum = 0;
  long Sum2 = 0;
  
  	for(long i = 0; i < M; i++){
      Sum = v[i] + Sum; 
	
    }
  
	Sum2 = N - Sum;
  	
	if(Sum2 < 0){
      cout << -1;
    }
  
  else{
    cout << Sum2;
  }
  
  
  	
}

Measured memory_bytes: 3700
import java.util.Scanner;

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

    int D = scanner.nextInt();
    System.out.print("Christmas");
    for (int i = 0; i < 25 - D; i++) {
      System.out.print(" Eve");
    }
    System.out.println();
  }
}


Measured memory_bytes: 20948
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int,int> mii;
 
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
#define FORd(i,a,b) for (int i = b-1; i >= a; i--)
#define F0Rd(i,a) for (int i = a-1; i >= 0; i--)
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
 
const int MOD = 1000000007;
double PI = 4*atan(1);
 
ll sum[100001], asum[100001];
vi neg;

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int N; cin >> N;
	cin >> sum[1]; asum[1] = sum[1];
	
	FOR(i,2,N+1) {
		char op; int A;
		cin >> op >> A;
		if (op == '-') neg.pb(i), A = -A;
		sum[i] = sum[i-1]+A;
		asum[i] = asum[i-1]+abs(A);
	}
	ll ans = sum[N];
	neg.pb(N+1);
	F0R(i,neg.size()-1) {
		ll cur = sum[neg[i]-1];
		cur -= (asum[neg[i+1]-1]-asum[neg[i]-1]);
		cur += (asum[N]-asum[neg[i+1]-1]);
		ans = max(ans,cur);
	}
	cout << ans;
}

Measured memory_bytes: 2296
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a, b, k;
    cin, k, a, b;
    bool ok = false;
    REP(i, a, b + 1) {
        ok |= ((i % k) == 0);
    }
    cout << (ok ? "OK" : "NG") << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <queue>
#include <math.h>
#include <unordered_map>

using namespace std;

#define _USE_MATH_DEFINES

class Solution {
private:
public:
};

int main() {
    double radius;
    cin >> radius;
    cout << 2 * M_PI * radius << endl;
}

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

using namespace std;
typedef long long ll;
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; }
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL << 60;

int main(){

  int a,b;cin>>a>>b;

  if(a-2*b<=0)out(0);
  else out(a-2*b);

  return 0;
}


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

int main(){
    int n;
    int A[100+1][100+1];

    cin>>n;

    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            A[i][j]=0;
        }
    }

    rep(i,n){
        int u,k;
        cin>>u>>k;
        rep(j,k){
            int v;
            cin>>v;
            A[u][v]=1;
        }
    }

    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(j-1) cout<<" ";
            cout<<A[i][j];
        }
        cout<<endl;
    }


    return 0;
}


Measured memory_bytes: 3132
#include <stdio.h>

int N,A[2][100];

int main()
{
	scanf ("%d",&N);
	for (int i=0;i<2;i++){
		for (int j=0;j<N;j++){
			scanf ("%d",&A[i][j]);

			int p = 0;
			if (i) p = A[i-1][j];
			if (j) p = p < A[i][j-1] ? A[i][j-1] : p;
			A[i][j] += p;
		}
	}

	printf ("%d\n",A[1][N-1]);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int N;
vector<int> a;

int main() {
    cin >> N;
    a.resize(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    int ans = 0;
    for (int i = 0; i < N; i++) ans += a[i] -1;

    /*
    ll product = 1;
    for (int i = 0; i < N; i++) product *= a[i];
    ll modu = product - 1;
    ll ans = 0;
    for (int i = 0; i < N; i++) ans += modu % a[i];
    */
    cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>

#define rep_ui(k,n)      for(ui  i = (k); i < (n); ++i)
#define rep_si(k,n)      for(int i = (k); i < (n); ++i)
#define rep_ul(k,n)      for(ul  i = (k); i < (n); ++i)
#define rep_sl(k,n)      for(ll  i = (k); i < (n); ++i)
#define rep_ui_down(k,n) for(ui  i = (k); i > (n); --i)
#define rep_si_down(k,n) for(int i = (k); i > (n); --i)
#define rep_ul_down(k,n) for(ul  i = (k); i > (n); --i)
#define rep_sl_down(k,n) for(ll  i = (k); i > (n); --i)

#define rep_uj(k,n)      for(ui  j = (k); j < (n); ++j)
#define rep_sj(k,n)      for(int j = (k); j < (n); ++j)
#define rep_uj_down(k,n) for(ui  j = (k); j > (n); --j)
#define rep_sj_down(k,n) for(int j = (k); j > (n); --j)

#define rep(k,n)         rep_ui(k,n)

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

template<class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vc)
{
  boost::for_each(vc, [&os, &vc](T value) {
    os << value;
    if (value != vc.back())
      os << ' ';
    });
  return os;
}

template<class T1, class T2>
inline
std::ostream&
operator<<(std::ostream& os, const std::pair<T1, T2>& p)
{
  return os << p.first << ' ' << p.second;
}

void solve(void)
{
  ui A{}; std::cin >> A;
  ui B{}; std::cin >> B;

  ui ans = (A + B) / 2;
  std::cout << ((ans * 2 == A + B) ? std::to_string(ans) : "IMPOSSIBLE") << "\n";

  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 1010
#define INF 1e9
 
struct Intersection{
    int x,y;
};
 
struct State{
    int dist,v,dir,c;
    State(int dist,int v,int dir,int c) :
	dist(dist),v(v),dir(dir),c(c) {}
    bool operator < (const State &s)const{
	if(dist != s.dist){
	    return dist > s.dist;
	}else{
	    return c > s.c;
	}
    }
};
 
int M,N;
string src,dst;
vector<int> G[MAX];
Intersection n[MAX];
map<string,int> num;
 
int nextdir(int xs,int ys,int xt,int yt,int dir){
    if(dir == 0){
	if(xs < xt) return -1;
	if(ys > yt) return -1;
	if(xs > xt) return 3;
	return 0;
    }else if(dir == 1){
	if(ys > yt) return -1;
	if(xs > xt) return -1;
	if(ys < yt) return 0;
	return 1;
    }else if(dir == 2){
	if(xs > xt) return -1;
	if(ys < yt) return -1;
	if(xs < xt) return 1;
	return 2;
    }else{
	if(ys < yt) return -1;
	if(xs < xt) return -1;
	if(ys > yt) return 2;
	return 3;
    }
}
 
int getDist(int x1,int y1,int x2,int y2){
    return max(abs(x2-x1),abs(y2-y1));
}
 
void solve(){
    priority_queue<State> Q;
    int dist[MAX][4];
    fill(dist[0],dist[0]+MAX*4,INF);
    for(int i = 0 ; i < 4 ; i++){
	Q.push(State(0,num[src],i,1));
	dist[num[src]][i] = 0;
    }
    while(!Q.empty()){
	State s = Q.top(); Q.pop();
	int v = s.v,dir = s.dir;
	if(dist[v][dir] < s.dist) continue;
	if(v == num[dst]){
	    cout << s.c << endl;
	    return;
	} 
	Intersection ni = n[v];
	for(int i = 0 ; i < (int)G[v].size() ; i++){
	    Intersection u = n[G[v][i]];
	    int ndir = nextdir(ni.x,ni.y,u.x,u.y,dir);
	    if(ndir == -1) continue;
	    int ndist = s.dist + getDist(ni.x,ni.y,u.x,u.y);
	    if(ndist < dist[G[v][i]][ndir]){
		dist[G[v][i]][ndir] = ndist;
		Q.push(State(ndist,G[v][i],ndir,s.c+1));
	    }
	}
    }
    cout << "impossible" << endl;
}
 
int main(){
    string name,a,b;
    int x,y;
    while(cin >> M >> N, M){
	num.clear();
	for(int i = 0 ; i < MAX ; i++){
	    G[i].clear();
	}
	for(int i = 0 ; i < M ; i++){
	    cin >> name >> x >> y;
	    n[i+1] = (Intersection){x,y};
	    num[name] = i+1;
	}
	for(int i = 0 ; i < N ; i++){
	    cin >> a >> b;
	    G[num[a]].push_back(num[b]);
	    G[num[b]].push_back(num[a]);
	}
	cin >> src >> dst;
	solve();
    }
    return 0;
}

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

using namespace std;


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  string s;
  cin >> s;
  int n = 0;
  if (s == "SUN") {
    n = 7;
  } else if (s == "MON") {
    n = 6;
  } else if (s == "TUE") {
    n = 5;
  } else if (s == "WED") {
    n = 4;
  } else if (s == "THU") {
    n = 3;
  } else if (s == "FRI") {
    n = 2;
  } else if (s == "SAT") {
    n = 1;
  }
  cout << n << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main(){
    int n;
    scanf("%d",&n);
    printf("%d",a[n-1]);

}


Measured memory_bytes: 256
n = int(input())
A = list(map(int,input().split()))[::-1]


def b():
    if A[0] != 2:
        return -1
    else:
        ans = [2, 3]
        for i in range(1, n):
            r = ans[1] // A[i] * A[i]
            l = -((-ans[0] // A[i]) * A[i])
            # print(-ans[0] // A[i])
            # print(l, r)
            if r < l:
                return -1
            ans = [l, r+A[i]-1]
            # print(ans)
    return ans

ans = b()
if ans == -1:
    print(ans)
else:
    print(ans[0], ans[1])

Measured memory_bytes: 63856
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define f first
	#define s second
	
	using namespace std;
	int main()
	{
		std::ios::sync_with_stdio(false);
		ll n;
		cin>>n;
		ll arr[n];
		for(ll i=0;i<n;i++)
			cin>>arr[i];
		ll max=arr[0];
		ll sum=0;
		for(ll i=1;i<n;i++){
			if(arr[i]<max)
				sum+=(max-arr[i]);
			else
				max=arr[i];
		}
		cout<<sum;
		return 0;
	}


Measured memory_bytes: 5212
#include <stdio.h>
int main(void){
  int a, b;

  scanf("%d %d", &a, &b);

  if(a>=1 && a<=100 && b>=1 && b<=100){
    printf("%d %d\n", a*b, 2*a+2*b);
  }
  else{
    return 1;
  }
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int main(){
	int N;
	cin>>N;
	vector<int> x2y(2*N);
	vector<bool> isb(2*N);
	rep(t,2){
		rep(i,N){
			int x,y;
			cin>>x>>y;
			x2y[x] = y;
			isb[x] = t;
		}
	}
	vector<bool> used(2*N);
	int ans = 0;
	rep(x,2*N){
		if(isb[x]){
			int y = x2y[x];
			int mxy = -1, agx = -1;
			rep(i,x) if(!isb[i] && !used[i]){
				if(mxy<x2y[i] && x2y[i]<y){
					mxy = x2y[i];
					agx = i;
				}
			}
			if(agx!=-1){
				ans++;
				used[agx] = 1;
			}
		}
	}
	cout<<ans<<endl;
}


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

int main() {
    string a;
    string b;
    string c;
  
    cin >> a >> b >> c;
    int anum = a.size();
    int bnum = b.size();
    int cnum = c.size();
  
  

  
  int nowturn = 0;
  int nowa = 0;
  int nowb = 0;
  int nowc = 0;
  
    while(1){
    
     
      if(nowturn == 0){
         

        if(anum<=nowa){
          cout << "A" << endl;
          break;
        }
        
        if(a[nowa]=='a'){
          
          nowturn == 0;
        }else if(a[nowa]=='b'){
          nowturn = 1;
        }else if(a[nowa]=='c'){
          nowturn = 2;
        }
        
        nowa = nowa+1;
        
       
       
      }else if(nowturn == 1){
       
        if(bnum<=nowb){
           cout << "B" << endl;
          break;
        }
        
         if(b[nowb]=='a'){
          nowturn = 0;
        }else if(b[nowb]=='b'){
          nowturn = 1;
        }else if(b[nowb]=='c'){
          nowturn = 2;
        }
        
         nowb = nowb+1;
      }else if(nowturn == 2){
  
        if(cnum<=nowc){
          cout << "C" << endl;
          break;
        }
        
         if(c[nowc]=='a'){
          nowturn = 0;
        }else if(c[nowc]=='b'){
          nowturn = 1;
        }else if(c[nowc]=='c'){
          nowturn = 2;
        }
        
         nowc = nowc+1;
      }
       
       
    }
 

  
  return 0;
}

Measured memory_bytes: 256
S = input()

flag = True
for i in range(len(S)):
    if (i+1) % 2 == 0:
        #print(S[i])
        if(S[i] != 'L' and S[i] != 'U' and S[i] != 'D'):
            flag = False
    else:
        if(S[i] != 'R' and S[i] != 'U' and S[i] != 'D'):
            flag = False

if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#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];
	}

	int j = 1;
	int ans = 0;
	for( int i = 0; i < N; i++ ) {
		if( a[i] != j ) {
			ans++;
		}
		else j++;
	}
	if( ans == N ) ans = -1;

	cout << ans << endl;
}


Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N,M; cin >> N >> M;
    int cnt[N];
    rep(i,N) cnt[i]=0;
    map<int,bool>can;
    rep(i,M){
        int a; string s;
        cin >> a >> s;
        a--;
        if(s=="WA" && !can[a]){
            cnt[a]++;
        }
        if(s=="AC"){
            can[a]=true;
        }
    }
    int cntw=0;
    int cnta=0;
    rep(i,N){
        if(can[i]){
            cnta++;
            cntw+=cnt[i];
        }
    }

    cout << cnta << " " << cntw << endl;

}


Measured memory_bytes: 7296
#include "bits/stdc++.h"
#define int long long
#define range(i, a, b) for(int i = a; i < b; i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int MOD = 1e9 + 7, INF = 1e9;
using vi = vector <int>;
using vvi = vector <vi>;
//g++ -std==c++14

signed main(){
	string x, y;
	cin >> x >> y;

	sort(x.begin(), x.end());
	sort(y.rbegin(), y.rend());

	if(x < y)cout << "Yes" << endl;
	else cout << "No" << endl;
}


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


int main(void)
{
    int n;
    scanf("%d", &n);
    
    int max = 0;
    for (int i=1; i < n+1; i++){
        int cnt = 0;
        int tmp = i;
        while(1){
            if (i%2 != 0) break;
            else{
                cnt++;
                i /= 2;
            }
        }
        i = tmp;
        if (max < cnt) max = cnt;
    }


    printf("%d\n", (int)pow(2, max));



    return 0;
} 



Measured memory_bytes: 384
n = int(input())
w = [input() for i in range(n)]
ans = "No"
l=0
t = w[0]
i=0
while(True):
    if len(set(w))!=n:
        break
    for s in w:
        if i==0:
            i+=1
        else:
            if t[len(t)-1:]==s[0]:
                l+=1
            t=s
    break
if l+1==n:
    ans="Yes"
print(ans)


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

using namespace std;

typedef long long ll;

void solve(){
    int k;
    cin >> k;
    int gcd[300][300];
    for(int i=1; i<300; i++)
        for(int j = 1; j<300; j++)
            gcd[i][j] = __gcd(i, j);
    ll s = 0;
    for(int i=1; i<=k; i++)
        for(int j=1; j<=k; j++)
            for(int z = 1; z<=k; z++)
                s += gcd[gcd[i][j]][z];
    cout << s;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll t = 1, i = 1;
    //cin >> t;
    while(t--){
        solve();
        ++i;
    }
    return 0;
}


Measured memory_bytes: 4004
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

void solve() {
    int k, x;
    cin >> k >> x;

    for(int i = x - k + 1; i < k+x; i++){
        if(i != x - k + 1) cout << " ";
        cout << i;
    }
    cout << endl;
}

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

Measured memory_bytes: 256
N ,K = map(int, input().split())
A = list(map(int, input().split()))
B = [0]
C = {} 
C[0] = 0
cnt = 0
jdg = 0
q = 0
while jdg == 0:
    i = A[q]-1
    q = i
    if q in C:
        l = C[q]
        #print(q,l)
        break
    cnt += 1
    B.append(i)
    C[i] = cnt
r = cnt+1
#print(q)
#print(B)
#print(C)
#print(l)
#print(r)
H = B[l:r]
#print(H) 
M = (K-l)%(r-l)
#print(N-l,M)
if K >= r:
	print(H[M]+1)
else:
  print(B[K]+1)


Measured memory_bytes: 124892
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
#include<stack>
#include <sstream> 
#include <limits>
#include <numeric>
#include<string.h>
#include<set>
using namespace std;
#define ll long long int
//typedef vector<int> V;
//typedef vector<V> VV;
//typedef vector<VV> VVV;
using namespace std;

int main() {
	int n,d,c=0;
	long double x[100][100];
	cin >> n >> d;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < d; j++) {
			cin >> x[i][j];
		}
	}
	for (int i = 0; i < n-1; i++) {
		for (int j = i + 1; j < n; j++) {
			long double sum = 0.0;
			for (int k = 0; k < d; k++) {
				sum += (x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
			}
			sum = sqrt(sum);
			if (ceil(sum) == floor(sum)) {
				c++;
			}
		}
	}
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<"="<<x
#define nl cout<<"\n"
#define frn(i,n) for(int i = 0;i < n;i++)
#define fr(i,a,b) for(int i = a;i < b;i++)
#define pb push_back
using namespace std;


int main() {
  int d,n;
  cin>>d>>n;
  int mul = 1;
  frn(i,d) mul *= 100;
  if(n==100) cout<<(n+1)*mul;
  else cout<<n*mul;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
using namespace std;
int main(){
	int n,i,j;
	scanf("%d",&n);
	if(n%2==0){
		printf("%d\n",n*(n-2)/2);
		for(i=1;i<=n;i++)
			for(j=1;j<i;j++)
				if(j+i!=n+1) printf("%d %d\n",j,i);
	}
	else{
		printf("%d\n",(n-1)*(n-3)/2+(n-1));
		for(i=1;i<n;i++)
			for(j=1;j<i;j++)
				if(j+i!=n) printf("%d %d\n",j,i);
		for(i=1;i<n;i++) printf("%d %d\n",i,n);
	}
	return 0;
}


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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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; }

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

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); }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

char G[1005][1005];
int dp[1005][1005];
bool visited[1005][1005];

int main(){
  int h,w; cin>>h>>w;
  rep(i,h) rep(j,w) cin>>G[i][j];
  
  dp[0][0]=1;
  
  queue<pii> q;
  q.emplace(0,0);
  while(!q.empty()){
    int y=q.front().first, x=q.front().second; q.pop();
    rep(i,2){
      int ny=y+dy[i], nx=x+dx[i];
      if(inside(ny,nx,h,w) && G[ny][nx]=='.'){
        (dp[ny][nx]+=dp[y][x])%=MOD;
        if(!visited[ny][nx]) {
          q.emplace(ny,nx);
          visited[ny][nx]=true;
        }
      }
    }
  }
  cout<<dp[h-1][w-1]<<endl;
}
 

Measured memory_bytes: 6144
n = int(input())
a = list(map(int, input().split()))
s = []
for i in range(n-1):
    s.append(abs(a[i]-a[i+1]))

S = abs(a[0]) + sum(s) + abs(a[-1])
for i in range(n):
    ans = S
    if i == 0:
        ans = ans - abs(a[0]) - s[0] + abs(a[1])
    elif i == n-1:
        ans = ans - abs(a[-1]) - s[-1] + abs(a[-2])
    else:
        if a[i-1] <= a[i+1]:
            if a[i] <= a[i-1]:
                ans -= 2*s[i-1]
            elif a[i+1] <= a[i]:
                ans -= 2*s[i]
        else:
            if a[i] <= a[i+1]:
                ans -= 2*s[i]
            elif a[i-1] <= a[i]:
                ans -= 2*s[i-1]
    print(ans)



Measured memory_bytes: 14040
#include <bits/stdc++.h>
using namespace std;
#define REP(i, t) for (int i = 0; i < t; i++)

int main()
{
    int N, M;
    string s[110], t[110];
    set<string> kinds;
    cin >> N;
    REP(i, N) cin >> s[i], kinds.insert(s[i]);
    cin >> M;
    REP(i, M) cin >> t[i], kinds.insert(t[i]);

    int now_max = 0;
    for (string c : kinds)
    {
        int now_get = count(&s[0], &s[N], c) - count(&t[0], &t[M], c);
        now_max = max(now_max, now_get);
    }

    cout << now_max << endl;

    return 0;
}


Measured memory_bytes: 256
n=input()
l=len(n)
if n[l-1]=='3':
	print("bon")
else : 
	if n[l-1] == '0' or n[l-1] == '1' or n[l-1]=='6' or n[l-1]=='8':
		print("pon")
	else:print("hon")

Measured memory_bytes: 9052
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

/*
*/

ll m,d,ans;

void init(){
	cin>>m>>d;
}

int main(void){
	init();
	reg(i,1,m){
		reg(j,1,d){
			ll d1=j%10,d10=j/10;
			if(d1>=2 && d10>=2 && i==d1*d10)ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

#define rep(i,st,ed) for (int i=st;i<=ed;++i)
#define ls (now<<1)
#define rs (now<<1|1)

typedef long long LL;
const LL INF=1e15;
const int N=200005;

struct SegTree {
	LL min[N<<2],tag[N<<2];

	void push_down(int now) {
		if (!tag[now]) return ;
		LL w=tag[now]; tag[now]=0;
		tag[ls]+=w,tag[rs]+=w;
		min[ls]+=w,min[rs]+=w;
	}

	void add(int now,int tl,int tr,int l,int r,LL v) {
		if (r<l) return ;
		if (tl>=l&&tr<=r) return (void) (min[now]+=v,tag[now]+=v);
		int mid=(tl+tr)>>1;
		push_down(now);
		if (l<=mid) add(ls,tl,mid,l,r,v);
		if (mid+1<=r) add(rs,mid+1,tr,l,r,v);
		min[now]=std:: min(min[ls],min[rs]);
	}

	void set(int now,int tl,int tr,int x,LL v) {
		if (tl==tr) return (void) (min[now]=v);
		int mid=(tl+tr)>>1;
		push_down(now);
		if (x<=mid) set(ls,tl,mid,x,v);
		else set(rs,mid+1,tr,x,v);
		min[now]=std:: min(min[ls],min[rs]);
	}

	LL query(int now,int tl,int tr,int l,int r) {
		if (r<l) return INF;
		if (tl>=l&&tr<=r) return min[now];
		int mid=(tl+tr)>>1; LL qx=INF,qy=INF;
		push_down(now);
		if (l<=mid) qx=query(ls,tl,mid,l,r);
		if (mid+1<=r) qy=query(rs,mid+1,tr,l,r);
		return std:: min(qx,qy);
	}

	void build(int now,int tl,int tr) {
		min[now]=INF;
		if (tl==tr) return ;//(void) (min[now]=(opt)?(-tl):(tl));
		int mid=(tl+tr)>>1;
		build(ls,tl,mid),build(rs,mid+1,tr);
	}

	void change(int now,int tl,int tr) {
		if (tl==tr) return (void) (min[now]-=tl);
		int mid=(tl+tr)>>1;
		push_down(now);
		change(ls,tl,mid),change(rs,mid+1,tr);
		min[now]=std:: min(min[ls],min[rs]);
	}

	void debug(int now,int tl,int tr) { 
		if (tl==tr) return (void) (printf("%lld ", min[now]));
		int mid=(tl+tr)>>1;
		push_down(now);
		debug(ls,tl,mid),debug(rs,mid+1,tr);
	}
} T1,T2;

LL x[N];

int read() {
	int x=0,v=1; char ch=getchar();
	for (;ch<'0'||ch>'9';v=(ch=='-')?(-1):v,ch=getchar());
	for (;ch<='9'&&ch>='0';x=x*10+ch-'0',ch=getchar());
	return x*v;
}

int main(void) {
	LL n=read(),T=read(),a=read(),b=read();
	rep(i,1,T) x[i]=read();
	T1.build(1,1,n),T2.build(1,1,n);
	T1.set(1,1,n,a,abs(b-x[1])+a),T1.set(1,1,n,b,abs(a-x[1])+b);
	T2.set(1,1,n,a,abs(b-x[1])-a),T2.set(1,1,n,b,abs(a-x[1])-b);
	// T1.debug(1,1,n),puts("");
	rep(i,2,T) {
		LL d=abs(x[i]-x[i-1]);
		LL ra=T1.query(1,1,n,x[i],n)-x[i];
		LL rb=x[i]+T2.query(1,1,n,1,x[i]);
		LL rc=T1.query(1,1,n,x[i],x[i])-x[i]+d;
		LL res=std:: min(ra,std:: min(rc,rb));
		T1.tag[1]+=d,T2.tag[1]+=d;
		T1.set(1,1,n,x[i-1],res+x[i-1]),T2.set(1,1,n,x[i-1],res-x[i-1]);
		// T1.debug(1,1,n),puts("");
	} T1.change(1,1,n);
	printf("%lld", T1.min[1]);
	return 0;
}

Measured memory_bytes: 24832
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(void) {
    int N, X, Y;
    cin >> N >> X >> Y;

    vector<int> ans(N);
    for(int i=1; i<N; i++) {
        for(int j=i+1; j<=N; j++) {
            int d = min(j-i, abs(X-i) + abs(Y-j) + 1);
            ans[d]++;
        }
    }

    for(int k=1; k<N; k++) {
        cout << ans[k] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// (setq-default c-basic-offset 2)

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

  long long ret = 0;

  for (long long i = 1; i <= n; ++i) {
    long long j = n / i;
    long long s = i * j * (j + 1) / 2;
    ret += s;
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 3600
#include<stdio.h>
int main(){
 int i,j,r,c,hyo[100][100],sum[100]={0},sum2[100]={0},SUM=0,SUM2=0;
 scanf("%d%d",&r,&c);

 for(i=0;i<r;i++){
  for(j=0;j<c;j++){
   scanf("%d",&hyo[i][j]);
   sum[i]+=hyo[i][j];
  }
SUM+=sum[i];
 }
 for(j=0;j<c;j++){
  for(i=0;i<r;i++){
sum2[j]+=hyo[i][j];
   
  }

//SUM2+=sum2[j];
 }

 for(i=0;i<r+1;i++){
  for(j=0;j<c+1;j++){
   if(i==r && j==c) printf("%d\n",SUM);
   else if(i==r) printf("%d ",sum2[j]);
   else if(j==c) printf("%d\n",sum[i]);
   else printf("%d ",hyo[i][j]);
  }
 }

}


Measured memory_bytes: 2148
#include<stdio.h>
#include<stdlib.h>
int main()
{
  int n, t=1, i, j, k, y, s=0, s1=0, s2=0;
  scanf("%d",&n);
  int arr[n];
  for(i=0; i<n; i++)
  {
    scanf("%d",&arr[i]);
    s = s + arr[i];
  }
  while(t<n)
  {
    for(j=0; j<t; j++)
    {
      s1 = s1 + arr[j];
    }
    for(k=t; k<n; k++)
    {
      s2 = s2 + arr[k];
    }
    t++;
    y = abs(s1-s2);
    if(y<s)
    {
      s = y;
    }
    s1=0;
    s2=0;
  }
  printf("%d",s);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
char s[N];
int n, l[N], r[N], a[N], f[N], k[N];
int sf(int x) { return x == f[x] ? x : f[x] = sf(f[x]); }
int main() {
    scanf("%s%d", s + 1, &n);
    int m = strlen(s + 1);
    for (int i = 1; i <= m + 1; i++) {
        a[i] = s[i] - s[i - 1], f[i] = i;
    }
    for (int i = 1; i <= m + 1; i++) {
        f[sf(i)] = sf(m + 2 - i);
    }
    for (int i = 0; i < n; i++) {
        scanf("%d%d", &l[i], &r[i]);
        f[sf(l[i])] = sf(r[i] + 1);
    }
    for (int i = 1; i <= m + 1; i++) {
        k[sf(i)] = (k[sf(i)] + a[i] % 26 + 26) % 26;
    }
    bool ok = true;
    for (int i = 1; i <= m + 1; i++) {
        if (k[sf(i)]) {
            ok = false;
            break;
        }
    }
    puts(ok ? "YES" : "NO");
    return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

#define DEBUG(x) cerr << #x << " = " << x << endl

const int MAX_N = 1000000;
const int INF = (int)1e9;

int main() {
    vector<int> tetra;
    for(int i = 1, k; k = i * (i + 1) * (i + 2) / 6, k <= MAX_N; i++) {
        tetra.push_back(k);
    }

    vector<int> dp(MAX_N + 1, INF);
    vector<int> dp2(MAX_N + 1, INF);
    queue<int> Q;
    queue<int> Q2;
    for(int i = 0; i < (int)tetra.size(); i++) {
        dp[tetra[i]] = 1;
        Q.push(tetra[i]);
        if(tetra[i] % 2 == 1) {
            dp2[tetra[i]] = 1;
            Q2.push(tetra[i]);
        }
    }

    while(Q.empty() == false) {
        int k = Q.front(); Q.pop();
        for(int i = 0; i < (int)tetra.size() && k + tetra[i] <= MAX_N; i++) {
            if(dp[k + tetra[i]] > dp[k] + 1) {
                dp[k + tetra[i]] = dp[k] + 1;
                Q.push(k + tetra[i]);
            }
        }
    }

    while(Q2.empty() == false) {
        int k = Q2.front(); Q2.pop();
        for(int i = 0; i < (int)tetra.size() && k + tetra[i] <= MAX_N; i++) {
            if(tetra[i] % 2 == 0) continue;
            if(dp2[k + tetra[i]] > dp2[k] + 1) {
                dp2[k + tetra[i]] = dp2[k] + 1;
                Q2.push(k + tetra[i]);
            }
        }
    }

    for(int N; cin >> N, N > 0; ) {
        cout << dp[N] << ' ' << dp2[N] << endl;
    }
}

Measured memory_bytes: 12488
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int X = Integer.parseInt(sc.next());
        int Y = Integer.parseInt(sc.next());
        int[] x = new int[n];
        int[] y = new int[m];
        int min = 101;
        int max = -101;
        String ans = "No War";
        for(int i=0; i<n; i++) {
            x[i] = Integer.parseInt(sc.next());
            if(max < x[i]) max = x[i];
        }
        for(int i=0; i<m; i++) {
            y[i] = Integer.parseInt(sc.next());
            if(min > y[i]) min = y[i];
        }
        if(max >= min) ans = "War";
        if(min <= X || max >= Y) ans = "War";
        System.out.println(ans); 
    }
    public static int max(int a, int b) {
        if(a <= b) return b;
        else return a;
    }

}


Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main(){
	double T, D;
	cin >> T >> D;
	double ta, tb, da, db;
	cin >> ta >> tb >> da >> db;
	double temp = -1000;
	for(int i=0; i <= D/da+10; i++){
		for(int j=0; j <= D/db+10; j++){
			if(D < da*i + db*j) continue;
			if(da*i+db*j == 0) continue;
			double t = (ta*da*i+tb*db*j)/(da*i+db*j);
			if(abs(T-temp) > abs(T-t)) temp = t;
		}
	}
	printf("%.10f\n", abs(T-temp));
}

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

using namespace std;

void doc() {
}

void solve() {
    int n,k;
    cin >> n >> k;
    cout << (k <= (n + 1) / 2 ? "YES" : "NO");
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
    doc();
    solve();
}


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

using namespace std;

using ll = long long int;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int h, w;
vs board;
vvi warningBoard;

void f(int x, int y) {
	warningBoard[x][y] = -1;
	for (int dx = -1; dx <= 1; dx++) {
		for (int dy = -1; dy <= 1; dy++) {
			if (dx == 0 && dy == 0) {
				continue;
			}

			int nx = x + dx, ny = y + dy;
			if (nx < 0 || nx >= h || ny < 0 || ny >= w) {
				continue;
			}

			if (board[nx][ny] == '#') {
				continue;
			}

			warningBoard[nx][ny]++;
		}
	}
}

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

	cin >> h >> w;

	board.resize(h);
	warningBoard.resize(h, vi(w));

	for (int i = 0; i < h; i++) {
		cin >> board[i];
	}

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (board[i][j] == '#') {
				f(i, j);
			}
		}
	}

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cout << (warningBoard[i][j] == -1 ? "#" : to_string(warningBoard[i][j]));
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 256
# array = [*1..q].map { |_| gets.split.map(&:to_i) }
# n = gets.split.map(&:to_i)
# a = [*1..m].repeated_combination(n).to_a


n = gets.to_i

array = [*1..n].map { |_| gets.chomp }

puts array.uniq.length


Measured memory_bytes: 37976
fun main(args: Array<String>) {
    val n = readLine()!!.split(" ").map { it.toInt() }[0]
    val s = readLine()!!.split(" ")[0]
    val nagasa = s.length
    val ans = Array(nagasa){ 0 }
    for (i in 0..nagasa-1){
        val divideS = s.get(i)
        var a = divideS.toInt() + n
        if (a <= 90){
            ans[i] = a
            val answer = ans.map { it.toChar() }
            print(answer[i])
        } else {
            ans[i] = a - 26
            val answer = ans.map { it.toChar() }
            print(answer[i])
        }
    }
}




Measured memory_bytes: 118256
#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;
using ll = long long int;
using vec = vector<int>;
using P = pair<int,int>;
const int INF = 1e9+7;

int main() {
  string s, t;
  cin >> s >> t;
  int n = s.size();
  int sum = 0;
  rep(i,n) {
    if (s[i] != t[i]) sum++;
  }
  cout << sum << endl;
}


Measured memory_bytes: 3840
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
 
int main() {
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    string s[50] = {};
    for (int i = 0 ; i < h ; i++) cin >> s[i];
    for (int i = 0 ; i < h ; i++) {
        for (int j = 0 ; j < w; j++) {
            if ( s[i][j] == '#' ) {
        		bool y = 0;
        		if (i && s[i - 1][j] == '#') y = 1;
        		if (i + 1 < h && s[i + 1][j] == '#') y = 1;
        		if (j && s[i][j - 1] == '#') y = 1;
        		if (j + 1 < w && s[i][j + 1] == '#') y = 1;
        		if (y == 0) {
					cout << "No";
					return 0;
				}
			}
        }
    }
    cout << "Yes";
}


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

int main() {
    string s;
    cin >> s;
    vector<int> l(26,0);
    for (auto c:s) {
        l[c-'a']=1;
    }
        
    if (s.length()==26) {
        int li=-1;
        for (int i=s.length()-1;i>=1;i--) {
            if (s[i-1]-'a' < s[i]-'a') {li=i-1;break;}            
        }
        if (li==-1) {cout << -1 << endl;}
        else {
            string news = s.substr(li+1);
            sort(news.begin(),news.end());
            char po;for (auto pq:news) {
                if (pq>s[li]) {
                    po = pq;
                    break;
                }
            }
            cout << s.substr(0,li) << po << endl;
        }
    } 
    else {
        char t;
        for (int i=0;i<26;i++) {
            if (l[i] == 0) {t = char(i + 'a');break;}
        }
        cout << s << t << endl;
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

namespace ConsoleAppAtCoderIHC
{
    class Program
    {
        static void Main(string[] args)
        {
            // 入力
            var D = int.Parse(ReadLine());
            var c = new List<int>() { 0 };
            c.AddRange(ReadLine().Split(' ').Select(s => int.Parse(s)));
            var s = new List<int>[D + 1];
            for (int i = 1; i <= D; i++)
            {
                s[i] = new List<int>() { 0 };
                s[i].AddRange(ReadLine().Split(' ').Select(s => int.Parse(s)));
            }
            var t = new int[D + 1];
            for (int i = 1; i <= D; i++)
            {
                t[i] = int.Parse(ReadLine());
            }

            // 満足度計算
            var last = new int[27];
            var v = 0;
            for (int d = 1; d <= D; d++)
            {
                // 加算
                v += s[d][t[d]];

                // 最終開催日を更新
                last[t[d]] = d;

                // 減算
                var minus = 0;
                for (int i = 1; i <= 26; i++)
                {
                    minus += c[i] * (d - last[i]);
                }

                v -= minus;

                WriteLine(v);
            }
        }
    }
}


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

ll maxtime(ll x) {
    return (x+9) / 10 * 10;
}

ll remtime(ll x) {
    return maxtime(x) - x;
}
ll n;
ll a[5];
ll sum;
ll remmax = -987654321;

int main() {
    ios::sync_with_stdio(false);
    for (int i = 0; i < 5; i++) {
        cin >> a[i];
        sum += maxtime(a[i]);
        remmax = max(remmax, remtime(a[i]));
    }
    cout << sum - remmax << endl;
    return 0;
}


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

int main(void) {
    long long N;
    cin >> N;
    string name = "";
    int l = 1;
    long long sum = 26, m = 26;
    while (sum < N) {
        ++l;
        m *= 26;
        sum += m;
    }
    sum -= m;
    long long nn = N - sum - 1;
    while (l > 0) {
        --l;
        char c = (nn % 26L) + 'a';
        char cc[] = {c};
        string cs(cc, 1);
        name = cs + name;
        nn /= 26L;
    }
    cout << name << "\n";

    return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>

const int MAX_K = 100000;
const int MAX_N = 100;

int a[MAX_N];
bool isWinner[1 + MAX_K];

int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i <= k; i++) {
    isWinner[i] = false;
    for (int j = 0; j < n; j++) {
      if (i - a[j] >= 0) {
        isWinner[i] |= !isWinner[i - a[j]];
      } 
    }
    //printf("%d ", isWinner[i]);
  }
  if (isWinner[k])
    printf("First\n");
  else
    printf("Second\n");
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	string s;
	cin>>s;
	int param = 1;
	for(int i=1;i<s.size();++i) {
		if(s[i] == s[i-1]) {
			continue;
		}
		param++;
	}
	for(int i=1;i<=k;++i) {
		if(param >= 3) {
			param-=2;
		}else {
			if(param > 1)
				param--;
		}
	}
	cout<<n-param<<endl;
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = scan.nextInt();
        }
        Arrays.sort(a);
        int gcd = gcd_multi(N, a, -1);
        int[] x = new int[N];
        for (int i = 0; i < N; i++) {
            x[i] = a[i] / gcd;
        }
        int min_gcd_first = Integer.MAX_VALUE;
        int index_first = 0;
        for (int i = 1; i < N; i++) {
            int t = gcd(x[0], x[i]);
            if (t < min_gcd_first) {
                index_first = i;
                min_gcd_first = t;
            }
        }
        int min_gcd_last = Integer.MAX_VALUE;
        int index_last = 0;
        for (int i = 0; i < N-1; i++) {
            int t = gcd(x[N-1], x[i]);
            if (t < min_gcd_last) {
                index_last = i;
                min_gcd_last = t;
            }
        }
        gcd = Math.max(gcd, gcd_multi(N, a, 0));
        gcd = Math.max(gcd, gcd_multi(N, a, N-1));
        gcd = Math.max(gcd, gcd_multi(N, a, index_first));
        gcd = Math.max(gcd, gcd_multi(N, a, index_last));
        System.out.println(gcd);
    }
    public static int gcd_multi(int N, int[] a, int skip) {
        int gcd = 0;
        for (int i = 0; i < N; i++) {
            if (i == skip) {
                continue;
            }
            gcd = gcd(a[i], gcd);
        }
        return gcd;
    }

    public static int gcd(int x, int y) {
        if (y == 0) {
            return x;
        }
        int ans = gcd(y, x % y);
        return ans;
    }
}


Measured memory_bytes: 50748
import itertools

n, m, x = map(int, input().split())
c = []
for i in range(n):
    ci = list(map(int, input().split()))
    c.append(ci)

ans = 10**10
for v in itertools.product([0, 1], repeat=n):
    lst = [0 for i in range(m)]
    money = 0
    for i in range(n):
        if v[i] == 1:
            ci = c[i]
            for j in range(1, m+1):
                lst[j-1] += ci[j]
            money += ci[0]
    if min(lst) >= x:
        ans = min(ans, money)

if ans == 10**10:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 74100
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;
using Int = long long;
int main()
{
    Int N, C;
    cin >> N >> C;
    vector<Int> X(N+1), V(N+1);
    for (int i = 1; i <= N; i++) cin >> X[i] >> V[i];
    vector<Int> cw(N+1), ccw(N+1);
    vector<bool> cwb(N+1), ccwb(N+1);
    for (int i = 1; i <= N; i++) {
        cw[i] = cw[i-1] + V[i];
        ccw[i] = ccw[i-1] + V[N+1-i];
    }
    Int bestcw = 0, bestccw = 0;
    for (int i = 1; i <= N; i++) {
        Int s = cw[i] - X[i];
        if (s > bestcw) {
            bestcw = s;
            cwb[i] = true;
        }
    }
    for (int i = 1; i <= N; i++) {
        Int s = ccw[i] - (C - X[N+1-i]);
        if (s > bestccw) {
            bestccw = s;
            ccwb[i] = true;
        }
    }
    Int result = max(bestcw, bestccw);
    Int j;
    j = N;
    for (int i = 1; i <= N - 1; i++) {
        j = min(j, N - i);
        while (j > 0 && !ccwb[j]) j--;
        if (j == 0) break;
        result = max(result, cw[i] - 2*X[i] + ccw[j] - (C - X[N+1-j]));
    }
    j = N;
    for (int i = 1; i <= N - 1; i++) {
        j = min(j, N - i);
        while (j > 0 && !cwb[j]) j--;
        if (j == 0) break;
        result = max(result, ccw[i] - 2*(C - X[N+1-i]) + cw[j] - X[j]);
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3456