akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <queue>

#define rep(i,n) for(int i=0;i<(n);i++)
#define fr first
#define sc second
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};

using namespace std;
typedef pair<int,int> P;
int W,H;
string maze[100];
const int INF=1e9;

void solve() {
    int dp[100][100];
    rep(y,100) rep(x,100) dp[y][x]=INF;
    getchar();
    rep(y,2*H-1) getline(cin,maze[y]);

    queue<P> que;
    que.push(P(0,0));
    dp[0][0]=0;
    while(que.size()) {
        P p=que.front(); que.pop();
        rep(k,4) {
            int ny=p.fr+dy[k];
            int nx=p.sc+dx[k];
            int ny2=ny+dy[k];
            int nx2=nx+dx[k];
            if(!(0<=ny&&ny<2*H-1)) continue;
            if(!(0<=nx&&nx<2*W-1)) continue;
            if(!(0<=ny2&&ny2<2*H-1)) continue;
            if(!(0<=nx2&&nx2<2*W-1)) continue;
            if(dp[ny2][nx2]!=INF) continue;
            if(maze[ny][nx]=='1') continue;

            //printf("(%d, %d) -> (%d, %d)\n",p.fr,p.sc,ny2,nx2);
            dp[ny2][nx2]=dp[p.fr][p.sc]+1;
            que.push(P(ny2,nx2));
        }
    }

    int ans=dp[2*H-2][2*W-2];
    if(ans==INF) ans=0;
    else ans++;
    cout<<ans<<endl;
}

int main() {
    while(cin>>W>>H) {
        if(!W) break;
        solve();
    }
    return 0;
}

Measured memory_bytes: 1268
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        private const int MODULO = 1000000007;
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static IEnumerable<int> Solve(int N, int[] X)
        {
            var Y = X.OrderBy(x => x);
            int a = Y.ElementAt(N / 2 - 1);
            int b = Y.ElementAt(N / 2);
            return X.Select(x => (x < b) ? b : a);
        }
        static void Main(string[] args)
        {
            int N = ReadInt();
            int[] X = ReadInts();
            foreach (int ans in Solve(N, X))
            {
                Console.WriteLine(ans);
            }
        }
    }
}


Measured memory_bytes: 42232
x,y = map(int,input().split())

if ((x<0)and(y==0)) or ((x == 0)and(y>=0)):
  print(abs(abs(x)-abs(y)))
elif ((x==0)and(y<0))or((x>0)and(y==0)):
  print(abs(abs(x)-abs(y))+1)
elif ((x>0)and(y>0))or((x<0)and(y<0)):
  if x>y:
    print(abs(abs(x)-abs(y))+2)
  elif x == y:
    print(0)
  else:
    print(abs(abs(x)-abs(y)))
else:
  if (-1*x)>y:
    print(abs(abs(x)-abs(y))+1)
  elif (-1*x) == y:
    print(1)
  else:
    print(abs(abs(x)-abs(y))+1)

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

int main(){
  int D,N;
  cin >> D >> N;
  int ans=1;
  int i;
  for(i=1;i<=D;i++){
    ans*=100;
  }
  if(N!=100){
  ans*=N;
}else{
  ans*=101;
}
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,i;
  scanf("%d",&n);
  int a[n+1];
  long long min=0;
  for(i=0;i<n;i++)
    scanf("%d",&a[i]);
  for(i=1;i<n;i++){
    if(a[i-1]>a[i]){
      min+=(long long)(a[i-1]-a[i]);
      a[i]=a[i-1];
    }
  }
  printf("%lld\n",min);
  return 0;
}


Measured memory_bytes: 2504
#include <iostream>
#include <cstdio>
#include <cassert>
#include <ctime>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define all(x) (x).begin(), (x).end()

#ifdef LOCAL
#define dbg(x) cerr << #x " = " << x << endl;
#define idbg(x) #x " = " << x
#include "pretty_print.h"
#else
#define dbg(x)
#define idbg(x) ""
#endif

#ifdef _WIN32
#  define LLD "%I64d"
#else
#  define LLD "%lld"
#endif

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

template <typename T> T sqr(T x) { return x * x; }
template <typename T> T abs(T x) { return x < 0? -x : x; }
template <typename T> T gcd(T a, T b) { return b? gcd(b, a % b) : a; }
template <typename T> bool chmin(T &x, const T& y) { if (x > y) { x = y; return true; } return false; }
template <typename T> bool chmax(T &x, const T& y) { if (x < y) { x = y; return true; } return false; }


int main(int /* argc */, char** /* argv */)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifdef LOCAL
    assert(freopen("inp", "r", stdin));
    assert(freopen("out", "w", stdout));
    #endif

    string s;
    cin >> s;
    cout << s.substr(0, 3) << endl;

    cerr << "Time execute: " << clock() / (double)CLOCKS_PER_SEC << " sec" << endl;
    return 0;
}


Measured memory_bytes: 3764
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
using namespace std;

int main() {
	int n, m;
	string a[50], b[50];
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < m; i++)
		cin >> b[i];
	bool flag;
	for (int i = 0; i <= n - m; i++) 
		for (int j = 0; j <= n - m; j++) {
			flag = false;
			for (int k = 0; k < m; k++) {
				for (int l = 0; l < m; l++) {
					if (a[i + k][j + l] != b[k][l]) {
						flag = true;
						break;
					}
				}
				if (flag == true)break;
			}
			if (flag != true) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import deque

Q = deque()
q=int(input())

for _ in range(q):
    a = input().split()
    
    if a[0] == "0":
        if a[1] == "0":
            Q.appendleft(a[2])
        else:
            Q.append(a[2])
    elif a[0] == "1":
        print(Q[int(a[1])])
    else:
        if a[1] == "0":
            Q.popleft()
        else:
            Q.pop()


Measured memory_bytes: 34652
#include<bits/stdc++.h>
#define FOR(i,a,b) for (register int i=(a);i<=(b);i++)
#define For(i,a,b) for (register int i=(a);i>=(b);i--)
#define mem(i,j) memset(i,j,sizeof(i))
#define GO(u) for (register int j=f[u];j!=-1;j=nxt[j])
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define MP make_pair
using namespace std;
typedef long long ll;
const int N=20;
const int M=500;
const int P=1<<16;
int n,m,x,y,z,dp[N][P],G[N][N],tot,sum=0,g[P],ans;
inline int read()
{
	int x=0,f=1;
	char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') {x=(x<<1)+(x<<3)+c-'0';c=getchar();}
	return f*x;
}
inline void write(int x)
{
	if (x<0) putchar('-'),x=-x;
	if (x>9) write(x/10);
	putchar(x%10+'0');
	return;
}
int main()
{
//	freopen("data.in","r",stdin);
	mem(G,-1);
	n=read(),m=read();
	FOR(i,1,m)
	{
		x=read(),y=read(),z=read();
		sum+=z;
		G[x][y]=G[y][x]=z;
	}
	tot=(1<<n)-1;
	FOR(i,1,tot)
		FOR(j,0,n-1) if ((i>>j)&1)
			FOR(k,j,n-1) if ((i>>k)&1)
				if (G[j+1][k+1]!=-1) g[i]+=G[j+1][k+1];
	mem(dp,-1);
	dp[1][1]=0;
	FOR(S,1,tot)
	{
		FOR(i,0,n-1) if (((S>>i)&1)&&dp[i+1][S]!=-1)
		{
			FOR(j,0,n-1)
			{
				if ((S>>j)&1) continue;
				if (G[i+1][j+1]==-1) continue;
				dp[j+1][S|(1<<j)]=max(dp[j+1][S|(1<<j)],dp[i+1][S]+G[i+1][j+1]);
			}
			int ss=(tot xor S)|(1<<i);
			for (register int s=ss;s;s=(s-1)&ss)
			{
				if (!((s>>i)&1)) continue;
				dp[i+1][S|s]=max(dp[i+1][S|s],dp[i+1][S]+g[s]);
			}
		}
	}
	ans=sum-dp[n][tot];
	write(ans);
	return 0;
}

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

#define rep(n, i) for (int i = 0; i < (n); ++i)

using ll = long long;
using namespace std;

template <typename T>
auto
power (
    T   base,
    ll  exponent)
{
    decltype(base) result = 1;

    for (; exponent; exponent >>= 1) {
      if ( exponent & 1 ) {
        result *= base;
      }
      base *= base;
    }
    return result;
}

template <long long N>
class Modulo {
 public:
  using Type = decltype(N);
  Modulo (Type n = 0) : number_((N + n) % N) {}
  // unary operator
  auto operator - () const {
    return Modulo(-number_);
  }
  auto operator ~ () const {
    // Only if N is prime, and number_ and N are coprime
    return power(*this, N - 2);
  }
  // compound assign operator
  auto & operator += (const Modulo & m) {
    number_ = (number_ + m.number_) % N;
    return *this;
  }
  auto & operator -= (const Modulo & m) {
    return *this += -m;
  }
  auto & operator *= (const Modulo & m) {
    number_ = (number_ * m.number_) % N;
    return *this;
  }
  auto & operator /= (const Modulo & m) {
    return *this *= ~m;
  }
  // binary operator with type conversion
  friend auto operator + (Modulo lhs, const Modulo & rhs) {
    return lhs += rhs;
  }
  friend auto operator - (Modulo lhs, const Modulo & rhs) {
    return lhs -= rhs;
  }
  friend auto operator * (Modulo lhs, const Modulo & rhs) {
    return lhs *= rhs;
  }
  friend auto operator / (Modulo lhs, const Modulo & rhs) {
    return lhs /= rhs;
  }
  // stream operator
  friend auto & operator << (std::ostream & os, const Modulo & m) {
    return os << m.number_;
  }
  friend auto & operator >> (std::istream & is, Modulo & m) {
    // Note that number_ may be negative
    return is >> m.number_;
  }
 private:
  Type number_;
};

template <typename T>
auto
combination (
    std::size_t n,
    std::size_t k)
{
    static T fac_n = 1;
    static vector<T> invs(n + 1);
    static bool ready = false;

    if ( !ready ) {
      for (size_t i = 1; i <= n; ++i) {
        fac_n *= i;
      }
      cout << "fac_n = " << fac_n << endl;
      invs[n] = ~fac_n;
      for (size_t i = n; 1 <= i; --i) {
        invs[i - 1] = invs[i] * i;
      }
      cout << "invs[0] = " << invs[0] << endl;
      ready = true;
    }
    cout << "invs[k] = " << invs[k] << endl;
    cout << "invs[n - k] = " << invs[n - k] << endl;

    return fac_n * invs[k] * invs[n - k];
}

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

    using Number = Modulo<1'000'000'007ll>;

    // 2^n - c(n, 0) - c(n, a) - c(n, b)
    auto allsum = power(Number(2), n);

    auto nca = Number(1);
    rep(a, i) {
      nca *= (n - i);
    }
    rep(a, i) {
      nca /= (a - i);
    }

    auto ncb = nca;
    auto d = b - a;
    rep(d, i) {
      nca *= ((n - a) - i);
    }
    rep(d, i) {
      nca /= (b - i);
    }

    auto exclude = 1 + nca + ncb;
    cout << allsum - exclude << endl;
}


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

int main() {
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  
  //長針と短針の１２からの角度求める(ラジアン)
  double arh, arm, ar;
  arh = M_PI * (60.0 * h + m) / 360.0;
  arm = M_PI * m / 30.0;
  ar = abs(arh - arm); //長針と短針の間の角度
  
  double ans;
  ans = sqrt(pow(a, 2) + pow(b, 2) - (2 * a * b * cos(ar)));//余弦定理
  
  cout << fixed << setprecision(20) << ans << endl;//小数点以下桁数指定
}

Measured memory_bytes: 4228
program Traveling
    implicit none
    integer(4):: n,i
    integer(4):: t,x,y

    read*, n

    do i=1,n
        read*, t,x,y
        if (t < x+y .or. and(t,1) /= and(x+y,1)) then
            print*, 'No'
            stop
        end if
    end do

    print*, 'Yes'
end program Traveling

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

const int INF = 1100000000;

int main() {
  string str;
  cin >> str;
  for (int i = 0; i < str.size(); i++) {
    if (i % 2 != 0) {
      continue;
    }
    cout << str.at(i);
  }
  cout << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
vector<int> h(14);
vector<bool> hf(14);
bool ten(int x, int y);
int main(){
  string s;
  while(cin >>s){
    bool f = false;
    vector<int> a(13);
    for(int i=0; i<13; i++) a[i] = s[i]-'0';
    for(int i=1; i<=9; i++){
      int lot[10]={0};
      bool ax = true;
      for(int j=0; j<13; j++) h[j] = a[j];
      h[13] = i;
      for(int j=0; j<14; j++){
	hf[j] = true;
	lot[h[j]]++;
      }
      for(int j=1; j<10; j++) if(lot[j]>4) ax = false;
      if(ax){
	sort(h.begin(),h.end());
	if(ten(4,1)){
	  if(f) cout <<" ";
	  cout <<i;
	  f = true;
	}
      }
    }
    if(!f) cout <<"0";
    cout <<endl;
  }
  return 0;
}
bool ten(int x, int y){
  bool f=false;
  if(x == 0 && y == 0) return true;
  for(int i=0; i<14; i++){
    if(hf[i]){
      if(y!=0){
	for(int j=i+1; j<14; j++){
	  if(hf[j] && h[i] == h[j]){
	    hf[i] = false;
	    hf[j] = false;
	    f|=ten(x,0);
	    if(f) return f;
	    hf[i] = true;
	    hf[j] = true;
	    break;
	  }
	  else if(h[i]!=h[j]) break;
	}
      }
      if(x!=0){
	for(int j=i+1; j<14; j++){
	  if(hf[j] && h[i] == h[j]){
	    for(int k=j+1; k<14; k++){
	      if(hf[k] && h[i] == h[k]){
		hf[i] = false;
		hf[j] = false;
		hf[k] = false;
		f|=ten(x-1,y);
		if(f) return f;
		hf[i] = true;
		hf[j] = true;
		hf[k] = true;
		break;
	      }
	      else if(h[i]!=h[k]) break;
	    }
	  }
	  else if(h[i]!=h[j]) break;
	}
	for(int j=i+1; j<14; j++){
	  if(hf[j] && h[i]+1 == h[j]){
	    for(int k=j+1; k<14; k++){
	      if(hf[k] && h[i]+2 == h[k]){
		hf[i] = false;
		hf[j] = false;
		hf[k] = false;
		f|=ten(x-1,y);
		if(f) return f;
		hf[i] = true;
		hf[j] = true;
		hf[k] = true;
		break;
	      }
	      else if(h[i]+2<h[k]) break;
	    }
	  }
	  else if(h[i]+1<h[j]) break;
	}
      }
    }
  }
  return f;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
 
int main() {
  ios::sync_with_stdio(0); 
  cin.tie(0); 
  
  string a, b;
  cin >> a >> b;

  int m = a.size(), n =  b.size();

  if (m < n) {
    cout << "LESS" << "\n";
    return 0;
  }
  else if (m > n) {
    cout << "GREATER" << "\n";
    return 0;
  }


  for (int i = 0; i < m; ++i) {
    if (a[i] < b[i]) {
      cout << "LESS" << "\n";
      return 0;
    }
    else if (a[i] > b[i]) {
      cout << "GREATER" << "\n";
      return 0;
    }
  }

  cout << "EQUAL" << "\n";
}


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

int main() {
	int	N;
	cin >> N;
	multiset<int> ms;
	rep(i, N)
	{
		int	a, b;
		cin >> a >> b;
		if (a == 0)
		{
			ms.insert(b);
			cout << ms.size() << endl;
		}
		else if (a == 1)
			cout << ms.count(b) << endl;
		else if (a == 2)
			ms.erase(b);
		else
		{
			int c;
			cin >> c;
			for (multiset<int>::iterator it = ms.lower_bound(b); it != ms.upper_bound(c); it++)
				cout << *it << endl;
		}
	}
}



Measured memory_bytes: 12364
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	N := nextInt(sc)
	a := make([]int, N)
	for i := 0; i < N; i++ {
		a[i] = nextInt(sc)
	}
	sort.Ints(a)
	for i := 0; i+1 < N; i++ {
		if a[i+1] == a[i] {
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
}


Measured memory_bytes: 4992
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<math.h>

using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  vector< vector< bool > > s = vector< vector< bool > >(m, vector< bool >(n, 0));
  bool p[10] = {};
  for(int i = 0; i < m ; i++){
    int k; cin >> k;
    for(int j = 0; j < k; j++){
      int t;
      cin >> t;
      s[i][t-1] = 1;
    }
  }

  for(int i = 0 ; i < m ; i++){
    cin >> p[i];
  }
  int count = 0;
  for(int i = 0; i < pow(2, n); i++){
    int flag = 0;
    int b[10] = {};
    for(int j = 0; j < m; j++){
      for(int k = 0 ; k < n ; k++){
        b[j] += ((i & (int)pow(2,k)) / (int)pow(2, k)) & s[j][k];
//        cout << b[j] << ":" << ((i&(int)pow(2, k) >> k)&s[j][k]) << " ";
      }
//      cout << endl;
      if(b[j] % 2 != p[j]) flag = 1;
    }
    if(!flag) count++;
  }
  cout << count << endl;
}


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

int main(){
  int a,b,c,d;
  cin >>a >>b >>c >>d;
  cout << max(a*b,c*d) << endl;
  return 0;
}


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

if c%b:
    aoki = c//b + 1
else:
    aoki = c//b

if a%d:
    ta = a//d + 1
else:
    ta = a//d

if aoki > ta:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 9176
#include<stdio.h>

int main(int argc,char** argv)
{
	int X,A,B;
	int c;
	scanf("%d",&X);
	scanf("%d",&A);
	scanf("%d",&B);
	c = X - A;
	c = c % B;
	printf("%d\n",c);
	return(0);
}

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

int N, M;
int x[100005];
int l[100005];

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

    cin >> N >> M;
    for (int i = 0; i < M; i++) cin >> x[i];

    sort(x, x+M);
    
    for (int i = 0; i < M-1; i++) l[i] = x[i+1]-x[i];

    sort(l, l+M-1);

    int ans = 0;
    for (int i = 0; i < M-N; i++) ans += l[i];

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    string s;
    cin >> s;
    bool ok = 1;
    ok &= s[2] == s[3];
    ok &= s[4] == s[5];
    cout << (ok ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    ll x;
    cin >> x;
    ll ans = (x / 500LL) * 1000LL;
    x %= 500;
    ans += (x / 5LL) * 5LL;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPE(i,x) for(int i=0;i<=(int)(x);i++)
#define RREPE(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP(i,x) for(int i=((int)(x));i>0;i--)
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
const int INF=numeric_limits<int>::infinity();
const int MOD=1000000007;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
    int n, y, a, b, c;
    cin >> n >> y;
    REPE(i, 2000) {
        REPE(j, 2000) {
            a = i;
            b = j;
            c = n - i - j;
            if (c < 0) break;
            if (10000*i + 5000*j + 1000*c == y) {
              printf("%d %d %d\n", a, b, c);
              return 0;
            }
        }
    }
    a = b = c = -1;
    printf("%d %d %d\n", a, b, c);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);


      String b = sc.next();

      if(b.equals("A")) System.out.println("T");
      if(b.equals("T"))  System.out.println("A");
      if(b.equals("G"))  System.out.println("C");
      if(b.equals("C"))  System.out.println("G");

  }
}


Measured memory_bytes: 21844
#include <stdio.h>

int is_prime(int n) {
    if (n == 1) return 0;

    for (int i = 2; i < n; i++) {
        if (n % i == 0) return 0;
    }

    return 1;
}


int main(int argc, char *argv[]) {
    int n;

    scanf("%d", &n);

    for (int i = 31; i <= 55555; i += 5) {
        if (is_prime(i)) {
            printf("%s%d", i == 31 ? "" : " ", i);
            if (--n == 0) break;
        }
    }

    printf("\n");

    return 0;
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextFloat64() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	s := nextString()

	ans := 0
	var l, r string
	for len(s) > 1 {

		mid := len(s) / 2
		l = s[:mid]
		r = s[mid:]
		// fmt.Println(s, "l", l, "r", r)
		if l == r && ans > 0 {
			break
		}

		s = s[:len(s)-2]
		ans += 2
	}
	fmt.Println(len(l) + len(r))
}


Measured memory_bytes: 1772
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        String s = sc.next();

        sc.close();

        String reg = "[0-9]+";

        if (s.substring(0, a).matches(reg)
                && s.substring(a, a + 1).equals("-")
                && s.substring(a + 1).matches(reg)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23760
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF = 2e9;
#define LINF = 1e18;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << = << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO")
#define Yes(n) cout << ((n) ? "Yes" : "No")

int main(){

    int n;
    cin >> n;

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

    reverse(all(a));

    rep(i, n){
        cout << a[i];
        if(i < n-1)cout << " ";
    }
    cout << endl;

}


Measured memory_bytes: 3044
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n,k=LI()
  l=LI()

  if l.count(0)>0:
    k-=1
    l.remove(0)

  if k==0:
    print(0)
    exit()

  if len(l)==0:
    print(0)
    exit()

  idx=len(l)-1
  for i in range(len(l)):
    if l[i]>0:
      idx=i
      break
  if max(l)<0:
    idx=len(l)

  l1=[abs(x) for x in l[idx:]]
  l2=[abs(x) for x in l[:idx]]
  l2.reverse()

  # print(l1)
  # print(l2)

  mn=inf
  for i in range(len(l1)):
    if i+1>=k:
      mn=min(mn,l1[i])
    else:
      if len(l2)>=k-(i+1):
        # print(l1[i],l2[k-(i+1)-1])
        mn=min(mn,l1[i]+2*l2[k-(i+1)-1])

  for i in range(len(l2)):
    if i+1>=k:
      mn=min(mn,l2[i])
    else:
      if len(l1)>=k-(i+1):
        # print(l2[i],l1[k-(i+1)-1])
        mn=min(mn,l2[i]+2*l1[k-(i+1)-1])

  print(mn)

main()
# print(main())


Measured memory_bytes: 17120
#include<iostream>
using namespace std;
int main(){
  int n[101];
  int i;
  int num;
  cin >> num;
  for(i=0;i<num;i++) cin >> n[i];
  cout << n[num-1];
  for(i=1;i<num;i++) cout <<" "<< n[num-i-1];
  cout << endl;
  return 0;
}



Measured memory_bytes: 3112
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7


import collections
import itertools
import operator


class UnionFind:
    def __init__(self, elems=None):
        class KeyDict(dict):
            def __missing__(self, key):
                self[key] = key
                return key

        self.parent = KeyDict()
        self.rank = collections.defaultdict(int)

        if elems is not None:
            for elem in elems:
                _, _ = self.parent[elem], self.rank[elem]

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        else:
            self.parent[y] = x
        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1

    def are_same(self, x, y):
        return self.find(x) == self.find(y)

    def grouper(self):
        roots = [(x, self.find(x_par)) for x, x_par in self.parent.items()]
        root = operator.itemgetter(1)
        for _, group in itertools.groupby(sorted(roots, key=root), root):
            yield [x for x, _ in group]


def main(): 
    N = II()
    position = []
    for _ in range(N):
        position.append(LI())

    min_ = INF
    import itertools
    for A, B in itertools.combinations(range(N), 2):
        uf = UnionFind(range(N))
        p = position[A][0] - position[B][0]
        q = position[A][1] - position[B][1]
        # print(p,q)
        uf.unite(A, B)
        for X, Y in itertools.combinations(range(N), 2):
            if A == X and B == Y:
                continue
            if (p == position[X][0] - position[Y][0] and q == position[X][1] - position[Y][1]) or (p == position[Y][0] - position[X][0] and q == position[Y][1] - position[X][1]):
                uf.unite(X, Y)
        
        min_ = min(min_, len(list(uf.grouper())))
    print(1 if N == 1 else min_)

main()

Measured memory_bytes: 3700
while(n=gets.to_i)!=0
  puts n.times.map{gets.split.map(&:to_i)}.sort_by{|a,b|b}.reduce([[0,0]]){|a,b|a<<[a[-1][0]+b[0],b[1]]}.any?{|a,b|a>b}?"No":"Yes"
end

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

int main(){
	int N;
	cin>>N;
	vector<int>W(N);
	int s2=0;
	rep(i,N){
		cin>>W.at(i);
		s2+=W.at(i);
	}

	int min=abs(W.at(0)-s2-W.at(0));
	int s1=0;
	rep(i,N-1){
		s1+=W.at(i);
		s2-=W.at(i);
		if(abs(s1-s2)<min){
			min=abs(s1-s2);
		}
	}
	cout<<min;
	//int s1=W.at(0);
return 0;}

/*compile
g++ code.cpp
./a.out
run*/

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

using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef pair<ll, ll> P;

int main(){
    string s;
    int n;
        cin >> n >> s;
    int cnt=0;
        for(int i=0; i<s.size()-2;i++){
            if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
                cnt += 1;
        }
    cout << cnt << endl;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
a=[0]*n
for i in range(k):
  d=int(input())
  b=list(map(int,input().split()))
  for j in b:
    if a[j-1]==0:
      a[j-1]=1

      
ans=0
for i in range(n):
  if a[i]==0:
    ans+=1
print(ans)
    

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int N, X;
    cin >> N >> X;
    vector<int> L(N);
    rep(i, N) cin >> L[i];

    int d = 0, ans = 0, cur = 0;
    while (d <= X and cur < N) {
        ans++;
        d += L[cur++];
    }
    if (d <= X) ans++;

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define NUM 10
int main(){
  int n;
  int ball[NUM];
  int b[NUM];
  cin>>n;
  for(int c=0;c<n;c++){
    for(int i=0;i<NUM;i++){
      cin>>ball[i];
      b[i]=-1;
    }
    int x=0;
    for(int j=0;j<NUM-1;j++){
      int t=ball[j];
      while(j<NUM-1 && t>=ball[j+1]){
	b[x]=ball[j+1];
	x++;
	j++;
      }
    }
    int f=true;
    for(int j=1;j<NUM && b[j]>0;j++){
      if(b[j]<=b[j-1]){
        f=false;
	break;
      }
    }
    if(f)
      cout<<"YES"<<endl;
    else
      cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 1152
import java.util.*;

class Main{
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String[] s = sc.next().split("");
        int n = s.length;
        String[] s1 = new String[n/2];
        String[] s2 = new String[n/2];
        for(int i=0;i<(n-1)/2;i++){
            s1[i] = s[i];
        }
        for(int i=(n+3)/2-1;i<n;i++){
            s2[i-(n+3)/2+1] = s[i];
        }
        if(check(s1) && check(s2) && check(s)){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }

    public static boolean check(String[] a){
        int n = a.length/2;
        for(int i=0;i<n;i++){
            if(!a[i].equals(a[a.length-1-i])){
                return false;
            }
        }
        return true;
    }
}


Measured memory_bytes: 21844
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, A, B;

  std::cin >> N >> A >> B;

  if (N == 1) {
    std::cout << "Hello World" << std::endl;
  }
  else {
    std::cout << A + B << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a[200005];
int main(){
	long long h,sum=0,t=1;
	scanf("%lld",&h);
	while(h>0){
		sum+=t;
		h/=2;
		t*=2;
	}
	printf("%lld",sum);
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  rep(i, s.size()){
    if(s[i] == ','){
      s[i] = ' ';
    }
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n, x;
    cin>>n;
    vector<ll>v;
    for(ll i=0; i<n; i++)
    {
        cin>>x;
        v.push_back(x);
    }
    ll c = 0;
    for(ll i=0; i<n; i++)
    {
        for(ll j=i+1; j<n; j++)
        {
            for(ll k=j+1; k<n; k++)
            {
                if(v[i] != v[j] && v[i] != v[k] && v[j] != v[k])
                {
                    if(v[i]+v[j]>v[k] && v[i]+v[k]>v[j] && v[j]+v[k]>v[i]) c++;
                }
            }
        }
    }
    cout<<c<<endl;
    return 0;
}



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

int main()
{
	int n,t[100005],m,p,x,sum,sum2;
	while(scanf("%d",&n)!=EOF)
	{
		sum=0;
		for(int i=1;i<=n;i++)
		{
			scanf("%d",&t[i]);
			sum=sum+t[i];
		}
		scanf("%d",&m);
		for(int j=1;j<=m;j++)
		{
			scanf("%d",&p);
			scanf("%d",&x);
			sum2=sum+x-t[p];
			printf("%d\n",sum2);
		}
		    
	}
	return 0;
}


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

int main() {
	int n;
	cin >> n;
	int a = n / 1000;
	int b = (n - a * 1000) / 100;
	int c = (n - a * 1000 - b * 100) / 10;
	int d = n - a * 1000 - b * 100 - c * 10;
	if (a - b - c - d == 7) cout << a << "-" << b << "-" << c << "-" << d << "=7" << endl;
	else if (a - b - c + d == 7) cout << a << "-" << b << "-" << c << "+" << d << "=7" << endl;
	else if (a - b + c + d == 7) cout << a << "-" << b << "+" << c << "+" << d << "=7" << endl;
	else if (a + b + c + d == 7) cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl;
	else if (a - b + c - d == 7) cout << a << "-" << b << "+" << c << "-" << d << "=7" << endl;
	else if (a + b + c - d == 7) cout << a << "+" << b << "+" << c << "-" << d << "=7" << endl;
	else if (a + b - c + d == 7) cout << a << "+" << b << "-" << c << "+" << d << "=7" << endl;
	else if (a + b - c - d == 7) cout << a << "+" << b << "-" << c << "-" << d << "=7" << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>
using namespace std;

const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
#define INF 1e+8
#define EPS 1e-10
#define PB push_back
#define fi first
#define se second
#define ll long long 
#define reps(i,j,k) for(int i = (j); i < (k); i++)
#define rep(i,j) reps(i,0,j)
typedef pair<int,int> Pii;
typedef vector<int> vi;
int main(){
	int n;
	while(scanf("%d",&n),n){
		int blocks[256][4]={{0}};
		int W,H;
		reps(i,1,n){
			int type,way;
			scanf("%d%d",&type,&way);
			rep(j,4){
				blocks[i][j] = blocks[type][j];
			}
			blocks[i][way]++; 
			blocks[i][(way+2)%4] = -1*blocks[i][way];
		}
		int L,U,R,T;
		L = U = R = T = 0;
		rep(i,n){
			L = max(L,blocks[i][0]);
			U = max(U,blocks[i][1]);
			R = max(R,blocks[i][2]);
			T = max(T,blocks[i][3]);
		}
		W = L+R+1;
		H = U+T+1;
		printf("%d %d\n",W,H);
	}
	return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
bool comp(const pair<ll,ll> &a,const pair<ll,ll> &b){
	if(a.fs>b.fs){
		return true;
	}
	else if(a.fs==b.fs){
		if(a.sc<b.sc){
			return true;
		}
		else return false;
	}
	else return false;
}
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,n;
	cin>>n;
	vector< pair<ll,ll> > vc;
	ll V[n],C[n];
	for(i=0;i<n;i++){
		cin>>V[i];
	}
	for(i=0;i<n;i++){
		cin>>C[i];
	}
	for(i=0;i<n;i++){
		vc.ps({V[i],C[i]});
	}

	sort(all(vc),comp);
	ll mx=0; k=0; l=0;
	for(i=0;i<n;i++){
		if(vc[i].sc>vc[i].fs) continue;
		k+=vc[i].fs;
		l+=vc[i].sc;
		if(k-l>mx){
			mx=k-l;
		}
	}
	cout<<mx<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define last Last
#define int long long
/*char buf[1<<21],*p1=buf,*p2=buf;
inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}*/
#define gc getchar
inline int read()
{
	int ret=0,f=0;char c=gc();
	while(!isdigit(c)){if(c=='-')f=1;c=gc();}
	while(isdigit(c)){ret=ret*10+c-48;c=gc();}
	if(f)return -ret;return ret;
}
const int N=200005;
int n,d,next[N];
int l,r,s[N][30];
char a[N];
void KMP()
{
	int k=0;
	for(int i=2;i<=n;i++)
	{
		for(;k&&a[k+1]!=a[i];)k=next[k];
		next[i]=(k+=(a[k+1]==a[i]));
	}
	d=n-next[n];
}
int fib(int p,int c)
{
	if(p<=n)return s[p][c];
	if(p<=n*2)return s[n][c]+s[p-n][c];
	int ans1=s[n][c]+s[d][c],ans2=s[n][c];
	int a=n+d,b=n;
	for(;p>a+b;)
	{
		int c=ans1;
		ans1+=ans2; 
		ans2=c;
		c=a;
		a+=b;
		b=c;
	}
	return ans1+fib(p-a,c);
}
int suan(int p,int c)
{
	if (p<=n) return s[p][c];
	if(n%d==0){
		int ans=(p-n)/d*s[d][c]+s[n][c];
		return ans+s[(p-n)%d][c];
	}
	return fib(p,c);
}
signed main()
{
	scanf("%s",a+1);
	n=strlen(a+1)/2;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<26;j++)s[i][j]=s[i-1][j];
		s[i][a[i]-'a']++;
	}
	KMP();
	l=read(),r=read();
	for(int i=0;i<26;i++)
		printf("%lld ",suan(r,i)-suan(l-1,i));
}

Measured memory_bytes: 27648
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int mod(int x, int y){
    return x % y + (x < 0 ? y : 0);
}

int main() {
    int w, h;
    int dx[] = {1,1,1,0,0,0,-1,-1,-1}, dy[] = {1,0,-1,1,0,-1,1,0,-1};
    while (cin >> h >> w && w){
        vector<string> s(h);
        REP(i,h) cin >> s[i];

        map<string, int> mp;
        string ans;
        REP(si,h) REP(sj,w) REP(k,9){
            string res;
            res += s[si][sj];
            for (int i=mod(si+dx[k],h), j=mod(sj+dy[k],w); i!=si || j!=sj; i=mod(i+dx[k],h), j=mod(j+dy[k],w)){
                res += s[i][j];
                if (mp[res]){
                    if (res.length() > ans.length() || (res.length() == ans.length() && res < ans))
                        ans = res;
                }
                mp[res] = 1;
            }
        }
        if (ans.length() <= 1) cout << 0 << endl;
        else cout << ans << endl;
    }

    return 0;
}

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

#define ll long long int 
#define pii pair<int, int>
#define INF 0x3f3f3f3f
#define fi first
#define se second
#define f(n) for(int i = 0; i < n; i++)
#define f2(n) for(int i = 1; i <= n; i++)
#define t cout << "TESTE" << endl
#define debug(x) if(on)cout << x << endl
#define on true
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define pb push_back


vector<int> gems;
int resp;
vector<int> val, c;

int main(){

	fastio;

	int n;
	cin >> n;

	int aux;
	for(int i = 0; i < n; i++){
		cin >> aux;
		val.pb(aux);
	}

	for(int i = 0; i < n; i++){
		cin >> aux;
		c.pb(aux);
	}


	int resp = 0;
	for(int i = 0; i < n; i++)
		if(val[i] - c[i] > 0)
			resp += (val[i] - c[i]);
	

	cout << resp << endl;
		
	
return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
   int i, n, input, max=-1000000, min=1000000;
   long int sum;
   cin>>n;
   sum=0;
    for(i=1; i<=n; i++)
    {
        
        cin>>input;
        sum=sum+input;
        if(input<min){
            min=input;
        }
        if(input>max){
            max=input;
        }

    
       
   }
    
cout<<min<<" "<<max<<" "<<sum<<endl;



   
   
}


Measured memory_bytes: 3116
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = INT_MAX;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ O(logN)
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//





int main() {
    
    int N, W; cin >> N >> W;
    vector<int> w(N+1), v(N+1);
    for (int i = 1; i <= N; ++i) cin >> w[i] >> v[i];

    vector<vector<ll>> dp(N+1, vector<ll>(W+1));
    rep(i,N+1) {
        rep(j,W+1) dp[i][j] = 0;
    }

    for (int i = 1; i <= N; ++i) {
        for (int sum = 0; sum <= W; ++sum) {
            if (sum - w[i] >= 0) {
                dp[i][sum] = max(dp[i][sum], dp[i-1][sum-w[i]] + v[i]);
            }
            dp[i][sum] = max(dp[i][sum], dp[i-1][sum]);
        }
    }
    out(dp[N][W]);
    
    return 0;
}






Measured memory_bytes: 80256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  string s;
  cin >> s;
  int n = s.length();
  int num = 0;
  string ans = "";
  ans += s[0];
  for(int i = 1; i < n - 1; ++i){
    num++;
  }
  ans += to_string(num);
  ans += s[n - 1];
  cout << ans << endl;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static final Scanner sc = new Scanner(System.in);
    static final int MOD = (int) 1E9 + 7;
    
    public static void main(String[] args) {
        int a = nint();
        String s = nstr();
        System.out.println(a < 3200 ? "red" : s);
        
    }

    private static long nlong() {
        return sc.nextLong();
    }

    private static int nint() {
        return sc.nextInt();
    }

    private static String nstr() {
        return sc.next();
    }

    private static char[] nsToChars() {
        return sc.next().toCharArray();
    }

    private static long[] nlongs(int n) {
        return nlongs(n, 0, 0);
    }

    private static int[] nints(int n) {
        return nints(n, 0, 0);
    }

    private static int[] nints(int n, int padL, int padR) {
        int[] a = new int[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nint();
        return a;
    }

    private static long[] nlongs(int n, int padL, int padR) {
        long[] a = new long[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nlong();
        return a;
    }

    private static String[] nstrs(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = nstr();
        return a;
    }

    private static char[][] nsToChars2D(int h, int w) {
        return nsToChars2D(h, w, 0);
    }

    private static char[][] nsToChars2D(int h, int w, int pad) {
        char[][] a2 = new char[h + pad * 2][w + pad * 2];
        for (int i = 0; i < h; i++)
            System.arraycopy(nsToChars(), 0, a2[pad + i], pad, w);
        return a2;
    }
}


Measured memory_bytes: 21204
x = int(input())
if 400<=x<=599:
    print("8")
elif 600<=x<=799:
    print("7")
elif 800<=x<=999:
    print("6")
elif 1000<=x<=1199:
    print("5")
elif 1200<=x<=1399:
    print("4")
elif 1400<=x<=1599:
    print("3")
elif 1600<=x<=1799:
    print("2")
elif 1800<=x<=1999:
    print("1")

Measured memory_bytes: 9180
import java.util.*;
public class Main{
	
	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		char[] arr = scan.next().toCharArray();
		int answer = 700;
		for(int i=0; i<arr.length; i++) {
			if(arr[i] == 'o') {
				answer = answer+100;
			}
		}
		
		System.out.println(answer);
		
	}

}


Measured memory_bytes: 20948
#include <stdio.h>
#include <iostream>
#include <math.h>

using namespace std;

int main() {
	int n,y,b,r,t;
	double max = 0;
	int maxn;
	double ganri;

	while(1) {
		cin >> n;
		if (n == 0) {
			break;
		}
		cin >> y;

		for (int i = 0; i < n; i++) {
			cin >> b >> r >> t;

			if (t == 1) {
				ganri = 1.0 + (double)y * (double)r / 100.0;
			} else {
				ganri = pow(1.0 + (double)r / 100.0, y);
			}
			if (ganri > max) {
				max = ganri;
				maxn = b;
			}
		}
		cout << maxn << endl;
		max = 0;
	}

	return 0;
}

Measured memory_bytes: 1252
//     COMIN FOR YOU:)

#include<bits/stdc++.h>

using namespace std;

int main()
{   
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
  
    ios::sync_with_stdio(0);
    cin.tie(0);
      
    int n;cin>>n;

    if (n>=30)
      {
          cout<<"Yes";
      }  
      
    else
    cout<<"No";  


   return 0;
}

Measured memory_bytes: 3656
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(1e9+7)
#define INF 1e17
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

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

int fpow(int b,int p)
{
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin>>n;
	vector<int> v(n+2);
	v[0]=v[n+1]=0;
	For(i,1,n) cin>>v[i];
	int tot=0;
	For(i,1,n+1) tot+=abs(v[i]-v[i-1]);
	For(i,1,n){
		int ans=tot;
		ans-=abs(v[i]-v[i-1])+abs(v[i+1]-v[i]);
		ans+=abs(v[i-1]-v[i+1]);
		cout<<ans<<"\n";
	}
	return 0;
}





























Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define int long long
#define float double
#define endl "\n"
#define debug cout<<"Good uptill here"<<endl<<flush;
#define deb(x) cout<<#x<<":"<<x<<endl<<flush;

using namespace std;

const int inf = 1e17 + 7;
const int MOD = 1e7 + 9;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	//CODE FOR SPECIFIED INPUT AND OUTPUT
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin>>n;
	int h[n];
	for(int i=0;i<n;i++) cin>>h[i];
	vector<int> dp(n);
	fill(dp.begin(),dp.end(),inf);
	dp[0] = 0;
	for(int i=0;i<n;i++){
		if(i<n-1) dp[i+1] = min(dp[i+1],dp[i] + abs(h[i]-h[i+1]));
		if(i<n-2) dp[i+2] = min(dp[i+2],dp[i] + abs(h[i]-h[i+2]));
	}
	cout<<dp[n-1]<<endl;
	return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
 
int main (void) {
  int X, ans = 1;
  cin >> X;
  vector <int> mochi(X);
  for(int i = 0; i < X; i++) {
    cin >> mochi[i];
  }
  sort(mochi.begin(), mochi.end());
  for(int i = 0; i < X - 1; i++) {
    if(mochi[i] < mochi[i+1]) {
      ans++; 
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256