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

using namespace std;

int tab[100007];
int dp[100007];

int main()
{
    int N;
    cin >> N;
    for(int i=1; i<=N; i++)
        cin >> tab[i];
    dp[2]=abs(tab[1]-tab[2]);
    for(int i=3; i<=N; i++)
        dp[i]=min(dp[i-1]+abs(tab[i]-tab[i-1]), dp[i-2]+abs(tab[i]-tab[i-2]));
    cout << dp[N];
}

Measured memory_bytes: 1024
#include<stdio.h>
int z,f=1;
char i[9];
int main(){
	for(puts("?aa");fflush(stdout),scanf("%s",i);){
		if(*i-97)return!puts("!OUT");
		if(i[1]){
			if(f&1<<i[1]-97)return!puts("!OUT");
			f|=1<<i[1]-97;
			printf("?%ca\n",i[1]);
		}else{
			if(z++)return!puts("!OUT");
			puts("?aaa");
		}
	}
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define pb push_back
#define nl cout<<"\n"
#define F first
#define S second
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

const ll MOD = 1000000007;
ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

int main() 
{
    fastio();

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

    if( a < b )
    {
        cout<<string(b,'0'+a);
    }
    else
    {
        cout<<string(a,'0'+b);
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using 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 urng(i, a, b) for(int i = int(b) - 1; i >= int(a); i--)
#define urep(i, b) urng(i, 0, b)
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed

int main() {
  int n, a, b, ans = 0;
  //string s;
  cin >> n >> a;
  //vector<int> v(n), c(n);
  //if(1) {}
  //
  //for(int i = 0; i < n; i++){}
  cout << ((n >= 10)? a : a + (100 * (10 - n))) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll INFL = 1e18+100;
const ll MOD = 1e9+7;
const bool debug = 0;
//-----------------------------------------------//

int main() {
	int N, M;
	cin >> N >> M;
	
	int ans = M*1900 + (N-M)*100;
	ans *= pow<int>(2, M);
	cout << ans << endl;
	return 0;
}


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

int main()
{
    int k;
    cin>>k;
    while(k%5 !=0)
    {
        k--;
    }
    int huncun = 0;
    int fivcun = 0;
    while(k >= 500)
    {
        huncun ++;
        k = k - 500;
    }
    while(k> 0)
    {
        fivcun++;
        k = k - 5;
    }
    cout<< huncun * 1000 + fivcun * 5 << endl;

}


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

signed main() {
	int x; cin >> x;
	if (x == 3 || x == 5 || x == 7)cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
/*
  Contest 103
  A - Task Scheduling Problem
  Rakesh Kumar --> 27/09/2020
 */

#include <bits/stdc++.h>

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

    std::vector<int> v(3, 0);
    std::cin >> v[0] >> v[1] >> v[2];
    std::sort(v.begin(), v.end());
    std::cout << v[2] - v[1] + v[1] - v[0] << std::endl;

    return 0;
}


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

bool check(string s) {
	if (s[0] != 'A') return false;
	
	int c = 0;
	for (int i = 2; i < s.length() - 1; i++) {
		if (s[i] == 'C') {
			c++;
		}
	}
	if (c != 1) return false;
	int upper = 0;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] >= 'A' && s[i] <= 'Z') {
			upper++;
		}
	}
	if (upper != 2) return false;
	return true;
}

int main() {
	string s;
	cin >> s;
	if (check(s)) {
		cout << "AC" << endl;
	}
	else {
		cout << "WA" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>

using namespace std;

vector<int> edge[100001];

int dfs(int v){
    vector<int> fight;
    for(int u:edge[v])fight.push_back(dfs(u));
    if(fight.size()==0)return 0;
    sort(ALL(fight));
    for(int i=1;i<fight.size();i++){
        if(fight[i]<=fight[i-1])fight[i]=fight[i-1]+1;
    }
    return fight.back()+1;
}


int main(){

    int N;cin>>N;
    REP(i,N-1){
        int a;cin>>a;
        edge[a].push_back(i+2);
    }
    cout<<dfs(1)<<endl;

    return 0;
}

Measured memory_bytes: 15104
#include <iostream>
using namespace std;
int main() {
  int n;
  while(cin>>n) {
    for(int i=0; i<10; i++) {
      if(n&1) {
	cout << (1<<i);
	if(n>>1) cout << " ";
      }
      n >>= 1;
    }
    cout << endl;
  }
  return 0;
}

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
// const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int N;
  cin >> N;
  vector< int > A(N);
  cin >> A;
  sort(begin(A), end(A));
  reverse(begin(A), end(A));
  int64 ret = 0;
  if(N % 2 == 0) {
    for(int i = 0; i + 1 < N / 2; i++) ret += A[i];
    for(int i = 1; i < N / 2; i++) ret += A[i];
    ret += A[N / 2 - 1];
  } else {
    for(int i = 0; i < N / 2; i++) ret += A[i];
    for(int i = 1; i <= N / 2; i++) ret += A[i];
  }
  cout << ret << "\n";
}

Measured memory_bytes: 3988
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;
const int MaxN = 1e5;

int main()
{
	int n,m;
	int a,b,c,d,e;
	int ans = 0;
	scanf("%d %d",&n,&m);
	for(int i = n;i <= m;i++)
	{
		a = i%10;
		b = i%100/10;
		c = i%1000/100;
		d=  i%10000/1000;
		e = i/10000;
		if(a==e&&b==d) ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
 
public class Main {
 
    private static final int BIG_NUM  = 2000000000;
 
    public static void main(String[] args) {
 
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
        int H,W;
 
        String work[] = new String[2];
 
        while(true){
 
            try {
                work = br.readLine().split("[\\s]+");
                if(work[0].equals("0") && work[1].equals("0"))break;
 
                H = Integer.parseInt(work[0]);
                W = Integer.parseInt(work[1]);
 
                for(int row = 0; row < H; row++){
                    for(int col = 0; col < W; col++){
                        System.out.printf("#");
                    }
                    System.out.printf("\n");
                }
 
                System.out.printf("\n");
 
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}


Measured memory_bytes: 62060
#include<iostream>
#include<fstream>
#include<sstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
using namespace std;

int main(){
	char mat[50];
	map<string,int> table;
	int maxi=0;
	string longest="",most="";
	while(scanf("%s",mat)!=EOF){
		string word(mat);
		table[word]++;
		if(table[word]>maxi){
			maxi = table[word];
			most = word;
		}
		if(word.size()>longest.size()){
			longest = word;
		}
	}
	cout<<most<<" "<<longest<<endl;
	return 0;
}

Measured memory_bytes: 1208
import math
X=int(input())
#A,B=map(int,input().split())
a=100
# A=list(map(int,input().split()))
#p=10**9+7
ma=[]
i=0
while True:
    i += 1
    a=a+math.floor(a*0.01)
    if a>=X:
        print(i)
        exit()

Measured memory_bytes: 9164
//
import java.math.*;
import java.util.*;
import java.io.*;
  
public class Main { 
  
    static BufferedReader in;
    static String file = "../in";

    public static void main(String[] args) throws Exception
    {
        int test = 10,   // 0 for local testing, 1 for std input
            _k = Integer.valueOf("1");
        if(test > 0) in = new BufferedReader(new InputStreamReader(System.in));
        else in = new BufferedReader(new FileReader(file));
        if(test < 0) {String[] str = in.readLine().split(" ");}

        new Main().a();

    }

    void a() throws Exception
    {
        char c = in.readLine().charAt(0);
        System.out.println((char)(c + 1));
    }
}

Measured memory_bytes: 21076
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;
int ai[105],bi[105];
int main()
{
    int a,b;
    cin>>a>>b;
    for(int i=1;i<=a;i++)
        cin>>ai[i]>>bi[i];
    int max1 = 1<<a,ant = 10000000;
    for(int i=0;i<max1;i++)
    {
        int cnt = 0,rr = b;
        for(int j=a-1;j>=0;j--)
        {
            if(i&(1<<j))
            {
                int tem = ai[j+1]*(j+1)*100+bi[j+1];
                if(tem>=rr)
                {
                    if(ai[j+1]*(j+1)*100>=rr)
                    {
                        if(rr%((j+1)*100)==0)
                            cnt+=rr/((j+1)*100);
                        else
                            cnt+=rr/((j+1)*100)+1;
                    }
                    else {
                        cnt+=ai[j+1];
                    }
                    rr-=tem;
                    break;
                }
                else
                {
                    rr -=tem;
                    cnt+=ai[j+1];
                }
            }
        }
        if(rr<=0)
        ant = min(ant,cnt);
    }
    cout<<ant<<endl;
    return 0;
}


Measured memory_bytes: 256
<?php
$n = 0;
$m = 0;
$pattern = 0;
list($n, $m) = sscanf(fgets(STDIN), "%d%d");

$pattern += $n>1 ? $n*($n-1) / 2 : 0;
$pattern += $m>1 ? $m*($m-1) / 2 : 0;

echo $pattern;
return ;

?>


Measured memory_bytes: 4728
#include<iostream>
#include <bits/stdc++.h>
#include<string>
#include<algorithm>
#include<utility>
#include<map>
using namespace std;
bool graph[8][8];

int dfs(int node,int N,bool visited[8]){

    bool all_visited = true;

    for(int i=0; i < N; ++i){
        if(visited[i]==false){
            all_visited = false;
        }
    }

    if(all_visited) return 1;
    int ret =0;

    for(int i=0; i < N; ++i){
        if(graph[node][i]==false) continue;
        if(visited[i]) continue;
        visited[i]=true;
        ret += dfs(i,N,visited);
        visited[i]=false;//次のノードに繰り返すから、もとに戻しておく
    }
    return  ret;
}


int main(){
    int N, M;
    cin >> N >> M;
    for(int i =0 ; i < M; ++i){
        int A, B;
        cin >> A >> B;
        graph[A-1][B-1]=graph[B-1][A-1]=true;
    }
    bool visited[8];
    for(int i = 0; i < N; ++i){
        visited[i]=false;
    }

    visited[0]=true;
    cout << dfs(0,N,visited) << endl;
    return 0;
}

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

int main() {
  ll n, a, b, c, d, e;
  cin >> n >> a >> b >> c >> d >> e;
  ll ans = ceil((double)n / min({a, b, c, d, e})) + 4;
  cout << ans << endl;
}

Measured memory_bytes: 256
<?php
$s = trim(fgets(STDIN));
$i=0;
$ans=0;
while($i<3){
if($s[$i]=="a"){
++$ans;
}elseif($s[$i]=="b"){
$ans+=10;
}elseif($s[$i]=="c"){
$ans+=100;
}
++$i;
}
if($ans==111){
echo "Yes";
}else{
echo "No";
}

Measured memory_bytes: 4856
import sys

def isM(s):
    if (s[0] == '0' and '1'<=s[1]<='9' ) or \
        (s[0] == '1' and s[1] in ('0', '1', '2')):
        return True
    return False

if __name__ == '__main__':
    input = sys.stdin.read()
    F, S = input[:2], input[2:]
    if isM(F) and not isM(S): print "MMYY"
    elif not isM(F) and isM(S): print "YYMM"
    elif isM(F) and isM(S): print "AMBIGUOUS"
    else: print 'NA'

Measured memory_bytes: 2568
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

const long long MOD = 1000000007;

char s[110];
char t[210];
long long szS;
long long szT;
long long k;

bool isAllEqual(char *s, int szS)
{
	for (int i = 1 ; i < szS ; i++)
	{
		if (s[0] != s[i])
			return false;
	}
	
	return true;
}

long long checkDupCount(char *s, int szS)
{
	long long ans = 0;
	for (int i = 1 ; i < szS - 1 ; i++)
	{
		if (s[i - 1] == s[i])
		{
			ans++;
			s[i]++;
			if (s[i] > 'z')
				s[i] = 'a';
			if (s[i] == s[i + 1])
			{
				s[i]++;
				if (s[i] > 'z')
					s[i] = 'a';
			}
		}
	}
	
	int tail = szS - 1;
	if (s[tail - 1] == s[tail])
	{
		ans++;
		s[tail]++;
		if (s[tail] > 'z')
			s[tail] = 'a';
	}
	
	return ans;
}

int main()
{
	scanf("%s\n", s);
	scanf("%d", &k);
	
	szS = strlen(s);
	strcpy(t, s);
	szT = strlen(t);
	
	bool allEqual = isAllEqual(s, szS);
	if (allEqual == true)
	{
		long long totalLength = szS * k;
		long long ans = totalLength / 2;
		printf("%lld\n", ans);
		return 0;
	}
	
	long long curCount = checkDupCount(t, szT);
	
	if (k == 1)
	{
		printf("%lld\n", curCount);
	}
	else
	{
		strcpy(t, s);
		strcat(t, s);
		szT = strlen(t);
		
		long long allCount = checkDupCount(t, szT);
		long long sectionCount = allCount - curCount;
		long long ans = sectionCount * (k - 1) + curCount;
		
		printf("%lld\n", ans);
	}
	
	return 0;
}


Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10**7)

n,m,q=map(int,input().split())
l=[list(map(int,input().split())) for i in range(q)]

def dfs(nl):
  if len(nl)==n:
    global ans
    t_ans=0
    for a,b,c,d in l:
      a-=1
      b-=1
      if nl[b]-nl[a]==c:
        t_ans+=d
    ans=max(ans,t_ans)
    return

  for i in range(nl[-1], m+1):
        dfs(nl+[i])

ans=0
for i in range(1,m+1):
  dfs([i])

print(ans)

Measured memory_bytes: 9204
H,W,D = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(H)]
Q = int(input())
LR = [list(map(int, input().split())) for _ in range(Q)]

X = [None]*(H*W+1) #X[i]:iが書かれたマスの座標
for h, row in enumerate(A):
  for w, a in enumerate(row):
    #A[h][w] = A_h+1_w+1
    X[a] = (h+1,w+1)

Y = [0]*(H*W+1) #X[i]: X[d]からDごとの系列で移動してきた移動量の和
for d in range(1,D+1):
  x = d
  while x+D <= H*W:
    Y[x+D] = Y[x] + abs(X[x+D][0]-X[x][0]) + abs(X[x+D][1]-X[x][1])
    x+=D

for l,r in LR:
  print(Y[r] - Y[l])
  
  


Measured memory_bytes: 42620
using System;
using System.Collections.Generic;
using System.Linq;

namespace atcoder_Begginer_Contest88_D
{
    class Program
    {
        static void Main(string[] args)
        {
            var hw = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var H = hw[0];
            var W = hw[1];

            var S = new string[H];
            for (var i = 0; i < H; i++) S[i] = Console.ReadLine();

            var num = SolveMaze(H, W, S);

            if (num == -1) Console.WriteLine(-1);
            else Console.WriteLine(S.Sum(str => str.Count(c => c == '.')) - num);
        }

        static int SolveMaze(int H, int W, string[]S)
        {
            Func<int, int, bool> isInside = (x, y) => 0 <= x && x < W && 0 <= y && y < H;
            var dx = new[] { 0, 1, 0, -1 };
            var dy = new[] { 1, 0, -1, 0 };

            var maze = new int[H, W];
            maze[0, 0] = 1;

            var que = new Queue<int>();
            que.Enqueue(0);
            que.Enqueue(0);

            while (que.Count > 0)
            {
                var x = que.Dequeue();
                var y = que.Dequeue();

                for (var i = 0; i < 4; i++)
                {
                    var nx = x + dx[i];
                    var ny = y + dy[i];

                    if (isInside(nx, ny) && maze[ny, nx] == 0 && S[ny][nx] == '.' )
                    {
                        maze[ny, nx] = maze[y, x] + 1;
                        que.Enqueue(nx);
                        que.Enqueue(ny);
                    }
                }
            }

            if (maze[H - 1, W - 1] == 0) return -1;
            else return maze[H-1,W-1];

        }
    }
}


Measured memory_bytes: 13524
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
#define mod 1000000007;
bool is_prime(lli x) {
  for(lli i = 2; i * i <= x; i++) {
    if(x % i == 0) return false;
  }
  return true;
}
int main() {
  lli A,B,C=1,D=0,E=0,F=0,G=0,H=0,N,M;
  vector<int>P(4,0);
  rep(i,0,3){
    cin >> A >> B;
    P[A-1]++;
    P[B-1]++;
  }
  Sort(P);
  if(P[3]>2)Out("NO");
  else Out("YES");
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main() {
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'A')cout << 'T';
        if (s[i] == 'C')cout << 'G';
        if (s[i] == 'G')cout << 'C';
        if (s[i] == 'T')cout << 'A';
    }
    cout << endl;
    return 0;
}

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

int main()
{
    int n;
    long long int k;
    cin >> n >> k;
    int *route = (int*) malloc( sizeof(int) * n );
    for( int i = 0; i < n; i++ ) 
    {
        cin >> route[i];
        route[i]--;
    }

    int *h = (int*) malloc( sizeof(int) * n );
    for( int i = 0; i < n; i++ ) h[i] = -1;

    int p = 0;
    int t = 0;
    while(true)
    {
        h[p] = t;
        p = route[p];
        t++;
        if( h[p] >= 0 ) break;
    }

    int sl = h[p];
    int l = t - h[p];
    if( k > sl )
    {
        int movet = (int)((k - sl) % l);
        for( int i = 0; i < movet; i++) p = route[p];
    }
    else
    {
        p = 0;
        for( int i = 0; i < k; i++) p = route[p];
    }

    cout << (p + 1);
}



Measured memory_bytes: 5220
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define endl '\n'
#define main() int main()
#define ff1(i,n) for(int i=1;i<=n;++i)
#define ff0(i,n) for(int i=0;i<n;++i)
#define pi acos(-1.0)
#define ms(a, x) memset(a, x, sizeof(a))
#define lowbit(x) ((x)&(-(x)))
#define pb push_back
#define binarycount __builtin_popcount(x)
#define tr t[root]
#define lson t[root << 1]
#define rson t[root << 1 | 1]
#define fir first
#define sec second
#define debug(x) cout<<x<<'\n'
#define sa(a) scanf("%d", &a)
#define sab(a, b) scanf("%d%d", &a, &b)
#define pa(a) printf("%d",a)
#define pab(a,b) printf("%d%d",a,b)
#define pii pair<string,int>
using namespace std;

#define maxn 100010
const int inf = 0x3f3f3f3f;
const int mod = 9973;
const double eps = 1e-8;
ll gcd(ll a, ll b) {return b==0?a:gcd(b, a%b);}
ll lcm(ll a, ll b) {return a/gcd(a, b)*b;}
int max(int x,int y){if(x>y) return x;return y;}
ll powmod(ll a,ll b){
    ull ans = 1, pow = a%mod;
    while(b) { if(b&1) ans = (ans*pow)%mod; pow = (pow*pow)%mod; b >>= 1; }
    return ans%mod;
}
main(){
	IO;
    int n,k;
	cin>>n>>k;
	vector<int> a(n+1);
	ff1(i,n) cin>>a[i];
	int dp[n+1];
	ms(dp,inf);
	dp[1]=0;dp[2]=abs(a[2]-a[1]);
	for(int i=3;i<=n;i++){
		for(int j=1;j<=k;j++){
			if(i-j>=1){
				dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
			}
		}
	}
	cout<<dp[n]<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0 ; i<(n) ; ++i)
#define rep1(i,n) for (int i=1 ; i<=(n) ; ++i)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
typedef long long ll;
using namespace std;
const ll MAX = 2500LL;
typedef pair <string, string> P;
const int INF = 100000000;

int main(){
  int x,n;
  cin >> x >> n;
  vector<int> p(n);
  vector<int> cnt(102);
  rep(i,n){
    cin >> p[i];
  }
  rep(i,n){
    cnt.at(p.at(i))++;
  }
  rep(i,300){
    if(cnt[x-i]==0){
      cout << x-i << endl;
      return 0;
    }
    if(cnt[x+i]==0){
      cout << x+i << endl;
      return 0;
    }
  }

  //int ans = INF;
  //int index = -1;
  // rep(i,102){
  //   if(cnt.at(i)>0 && (i!=0 || i!=101)) continue;
  //   if(ans > abs(x-i)){
  //     ans = abs(x-i);
  //     index = i;
  //   }
  // }
  //cout << index << endl;
  return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#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(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

int N;
int h[105];
bool used[105];

signed main()
{
	cin >> N;
	for (int i = 1; i <= N; ++i) cin >> h[i];

	queue<int> q;

	int ans = 0;

	while (1) {
		memset(used, 0, sizeof used);

		bool f = false;

		rep1(i, N) {
			if (used[i] or h[i] == 0) continue;
			q.push(i);

			while (q.size()) {
				int idx = q.front(); q.pop();

				if (used[idx]) continue;
				h[idx]--;
				used[idx] = true;

				if (idx - 1 >= 1 and h[idx - 1] > 0) q.push(idx - 1);
				if (idx + 1 <= N and h[idx + 1] > 0) q.push(idx + 1);
			}

			ans++;
		}

		rep1(i, N) if (h[i] > 0) f = true;

		if (not f) break;
	}

	cout << ans << endl;
}




Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
# https://atcoder.jp/contests/abc087/tasks/abc087_a
X = read_a_int()
A = read_a_int()
B = read_a_int()
print((X - A) % B)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
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; }
template<class T> void PrintVector(const vector<T> &vec) {for (auto val : vec) cout << val << " "; cout << endl;}
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int n, k; cin >> n >> k;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];

    sort(ALL(h));
    ll mini = INF;
    for (int i = 0; i + k - 1 < n; i++)
    {
        ll tmp = h[i + k - 1] - h[i];
        mini = min(mini, tmp);
    }
    cout << mini << endl;
}

Measured memory_bytes: 1024
#ifndef LOCAL
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
int fix(int x){
    return (x % MOD + MOD) % MOD ;
}
signed main(){
    fastio
    int n ;
    cin >> n ;
    vector<int> v(n) ;
    for(int i = 0; i < n; i++){
        cin >> v[i] ;
    }
    vector<int> sum(n + 1) ;
    for(int i = 0; i < n; i++){
        sum[i + 1] = sum[i] + v[i] ;
        sum[i + 1] %= MOD ;
    }
    int ans = 0 ;
    for(int i = 0; i < n - 1; i++){
        ans = (ans % MOD) + (v[i] * fix(sum[n] - sum[i + 1]) % MOD) % MOD ;
        ans %= MOD ;
    }
    cout << ans << endl;
    return 0; 
}

Measured memory_bytes: 6364
N  = int(input())
max = 1
max2nd = 0
max_index = 0

for index in range(N):
    a = int(input())
    if a >= max:
        max2nd = max
        max = a
        max_index = index
    elif a >= max2nd:
        max2nd = a

for index in range(N):
    if not index == max_index:
        print(max)
    else:
        print(max2nd)

Measured memory_bytes: 4540
#include<iostream>
#include<vector>

using namespace std;

typedef long long ll;

int H, W, K;
ll dp[101][8][1 << 7];
ll ruisekiwa[101][8];
vector<int> hikikata;
const ll MOD = 1000000007;

void calc_hikikata() {
	for (int bit = 0; bit < (1 << (W - 1)); bit++) {
		bool conti = false;
		for (int i = 0; i < W - 1; i++) {
			if ((bit & (1 << i))) {
				if(!conti)
				conti = true;
				else goto nxtroop;
			}
			else conti = false;

		}

		hikikata.push_back(bit);
	nxtroop:;
	}
}

int main() {
	cin >> H >> W >> K;

	calc_hikikata();

	dp[0][0][0] = 1;
	ruisekiwa[0][0] = 1;

	for (int i = 1; i <= H; i++) {
		for (int j = 0; j < W; j++) {
			for (int k = 0; k < hikikata.size(); k++) {
				int pattern = hikikata[k];
				if (j == 0) {
					if (pattern & 1) {
						dp[i][j][pattern] += ruisekiwa[i - 1][j + 1];
					}
					else {
						dp[i][j][pattern] += ruisekiwa[i - 1][j];
					}
				}
				else if (j == W - 1) {
					if (pattern & (1 << (W - 2))) {
						dp[i][j][pattern] += ruisekiwa[i - 1][j - 1];
					}
					else {
						dp[i][j][pattern] += ruisekiwa[i - 1][j];
 					}
				}
				else {
					if (pattern & (1 << (j - 1))) {
						dp[i][j][pattern] += ruisekiwa[i - 1][j - 1];
					}
					else if (pattern & (1 << j)) {
						dp[i][j][pattern] += ruisekiwa[i - 1][j + 1];
					}
					else {
						dp[i][j][pattern] += ruisekiwa[i - 1][j];
					}
				}

				dp[i][j][pattern] %= MOD;
				ruisekiwa[i][j] += dp[i][j][pattern];
				ruisekiwa[i][j] %= MOD;
			}

		}
	}

	ll ans = 0;
	for (int j = 0; j < hikikata.size(); j++) {
		ans += dp[H][K - 1][hikikata[j]];
		ans %= MOD;
	}


	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    int mx1, mx2;
    mx1 = mx2 = -1;
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
        if(a[i] > mx2) {
            mx1 = mx2;
            mx2 = a[i];
        } else if(a[i] > mx1) {
            mx1 = a[i];
        }
    }
    for(int i = 0; i < n; ++i) {
        if(a[i] != mx2)
            cout << mx2 << '\n';
        else
            cout << mx1 << '\n';
    }
}

Measured memory_bytes: 2432
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Vec2(T, n, m, xs, x0) vector<vector<T>> xs(n, vector<T>(m, x0))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(string, s);
    int n = (int)s.size();
    For(i, n-1){
        if(s[i] == s[i+1]){
            Cout(i+1, " ", i+2); return 0;
        }
    }
    For(i, n-2){
        if(s[i] == s[i+2]){
            Cout(i+1, " ", i+3); return 0;
        }
    }
    Cout("-1 -1");
}


Measured memory_bytes: 512
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

h, w = map(int, readline().split())
a = [list(map(int, readline().split())) for _ in range(h)]
cnt = 0
bf = []
af = []
for i in range(h):
    for j in range(w):
        if a[i][j] % 2 == 1:
            cnt += 1
            bf.append([i + 1, j + 1])
            if j == w - 1:
                if i == h - 1:
                    cnt -= 1
                    break
                a[i + 1][j] += 1
                af.append([i + 2, j + 1])
            else:
                a[i][j + 1] += 1
                af.append([i + 1, j + 2])
print(cnt)
for xy1, xy2 in zip(bf, af):
    print(*(xy1 + xy2))


Measured memory_bytes: 41212
#include <iostream>
#include <string>
#include <cctype>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;
int main(){
    string s, ans="AC"; cin >> s;
    if(s[0] != 'A') ans = "WA";
    int cnt = 0, n = s.length();
    if(!islower(s[1])) ans = "WA";
    if(!islower(s[n-1])) ans = "WA";
    for(int i = 2; i < n-1; i++){
        if(isupper(s[i])){
            if(s[i] == 'C') ++cnt;
            else ans = "WA";
        }
    }
    if(cnt != 1) ans = "WA";
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
def check(mask):
    for e in mask:
        if e==1: return True
    return False

def main():
    n,m=map(int,input().split(" "))
    ia=[list(map(int,input().split(" "))) for _ in range(n)]
    a=[[0 for _ in range(m)] for _ in range(n)]
    for i in range(n):
        for j in range(m):
            a[i][ia[i][j]-1]=j
    mask=[1 for _ in range(m)]
    res=1000
    while check(mask):
        cnt=[0 for _ in range(m)]
        for alst in a:
            mi=3000
            pos=-1
            for i in range(m):
                if alst[i]<mi and mask[i]==1:
                    pos=i
                    mi=alst[i]
            cnt[pos]+=1
        ma=max(cnt)
        res=min(res,ma)
        for i in range(m):
            if cnt[i]==ma: mask[i]=0

    print(res)            


main()

Measured memory_bytes: 5432
#define _USE_MATH_DEFINES
 
#include <iostream>
#include <cstdio>
#include <memory>
#include <string>
#include <cstdlib>
#include <set>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <cmath>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <cassert>
#include <chrono>
#include <memory>
 
using namespace std;
 
#define int long long
//region TEMPLATE
////@formatter:off
#define double long double
typedef long long ll;
typedef unsigned long long ull;
template<typename T>void __read(T &a) { cin >> a; }
template<typename T, typename ... Args> void __read(T &a, Args &... args) { cin >> a;__read(args...);}
#define make(t, ...) t __VA_ARGS__; __read(__VA_ARGS__)
#define makev(a, n) VI a(n); FOR(n) cin >> a[i];
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<pair<int, int>, int> PPII;
constexpr ll M7 = 1000000007ll;
constexpr ll M9 = 1000000009ll;
constexpr ll MFFT = 998244353ll;
template<class T> void outv(T &a) { for (auto &x : a) cout << x << ' '; }
static mt19937 rnd(static_cast<unsigned>(chrono::steady_clock::now().time_since_epoch().count())); // NOLINT(cert-err58-cpp)
auto __fast_io__ = (ios_base::sync_with_stdio(false), cin.tie(nullptr)); // NOLINT(cert-err58-cpp,cppcoreguidelines-interfaces-global-init)
////@formatter:on
//endregion
 
 
int32_t main() {
    make(int, n);
    cout << fixed << setprecision(10) <<  2 * n * M_PI;
 
    return 0;
}

Measured memory_bytes: 3804
#include<stdio.h>
int main(){
  int w,n,a,b,t,i;
  int r[31];
  scanf("%d %d",&w,&n);
  for(i=1;i<=w;i++)r[i]=i;
  while(n--){
    scanf("%d,%d",&a,&b);
    t=r[a];
    r[a]=r[b];
    r[b]=t;
  }
  for(i=1;i<=w;i++)printf("%d\n",r[i]);
  return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;cin>>s>>t;
  int m=s.size(),n=t.size(),flag=0,count=0;
  vector<char> a(m); vector<char> b(n);
  
  for(int i=0;i<m;i++)a.at(i)=s.at(i);    //sを一文字ずつaに格納
  for(int i=0;i<n;i++)b.at(i)=t.at(i);    //tを一文字ずつbに格納
  sort(a.begin(),a.end());                //aを小さい順にソート
  sort(b.begin(),b.end(),greater<int>()); //bを大きい順にソート

  if(m<n){                                //sの方が短いとき
    for(int i=0;i<m;i++){
      if(a.at(i)==b.at(i))continue;       //i文字目が一緒のときi++
      else if(a.at(i)<b.at(i))break;      //i文字目がs'の方が小さい(辞書順で前の)ときbreak
      else{                               //i文字目がt'の方が小さい(辞書順で前の)ときflagを立ててbreak
        flag++;
        break;
      }
    }
  }
  
  else{                                   //sがtより短くないとき
    for(int i=0;i<n;i++){
      if(a.at(i)==b.at(i))continue;
      else if(a.at(i)<b.at(i))break;      //i文字目がs'の方が小さい(辞書順で前の)ときbreak
      else{                               //i文字目がt'の方が小さい(辞書順で前の)ときflagを立ててbreak
        flag++;
        break;
      }
    }
    for(int i=0;i<n;i++)                 //nまで全文字が同じ場合か判定
      if(a.at(i)==b.at(i))count++;
    if(count==n)flag++;                  //nまで全文字同じならflagを立てる
  }
  
  if(flag>0)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s;
long long dfs(long long w,long long sum,long long c)
{
	if(w==s.size()) return (sum*(c==0));
	return (dfs(w+1,sum,c*10+s[w]-'0'))+(dfs(w+1,sum+c*10+s[w]-'0',0));
}
int main()
{
	cin>>s;
	cout<<dfs(0,0,0)<<endl;
	return 0;
}

Measured memory_bytes: 256
n = gets.to_i
a = []
b = []

n.times do
  sa,sb = gets.split.map(&:to_i)
  a << sa
  b << sb
end
sum = 0
(1..n).each do |i|
	s = ((a[-i] + sum) % b[-i])
  	if s > 0
    	sum += b[-i] - s
    end
end
puts sum

Measured memory_bytes: 3456
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
constexpr long INF = 1LL << 60;
constexpr int MOD = 1e9 + 7;

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int a; cin >> a;
    string s; cin >> s;
    if(a>=3200)cout<<s;
    else cout<<"red";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
    return a / GCD(a, b) * b;
}

int main()
{ ll n,m;
    cin>>n>>m;
  vector<int>a(n);
  ll lcm=1;
    rep(i,n)
    {ll ai;
    cin>>ai;
    a.at(i)=ai;
    lcm=LCM(lcm,ai);
    //cout << i<<endl;
    }
    lcm/=2;
   // cout << lcm<<endl;
    ll count=0;
    for (ll i = 1; i*lcm <= m; i+=2)
    {
        count++;
      //  cout << i*lcm<<endl;
    }
    rep(i,n)
    {
      if(lcm*2/a[i]%2==0)
      {count=0;}
    }
    cout << count <<endl;
    return 0;
}


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

using namespace std;
int N;
vector<int> W;
int ans = 300;

int main(){
  cin >> N;
  for(int i=0; i<N; i++){
    int w;
    cin >> w;
    W.push_back(w);
  }
  int sum,tmp = 0;
  for(int i=0; i<N; i++){
    sum = sum + W[i];
  }
  for(int i=0; i<N; i++){
    tmp = tmp + W[i];
    int a = sum - tmp;
    int b = sum - a;
    int diff = abs(a - b);
    ans = min(ans, diff);
  }

  cout << ans << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;
const int MOD = 1e9 + 7;

int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> v(n);
	rep(i, n) cin >> v[i];

	sort(all(v));
	reverse(all(v));
	int ans = 0;
	rep(i, k) ans += v[i];

	cout << ans << endl;

	return (0);
}


Measured memory_bytes: 3600
#include<stdio.h>
#define inf 1000000001

int count=0;

void merge(int s[],int left,int mid,int right){
    int n1=mid-left;
    int n2=right-mid;
    int L[n1+1],R[n2+1];
    int i;
    for(i=0;i<=n1-1;i++)L[i]=s[left+i];
    for(i=0;i<=n2-1;i++)R[i]=s[mid+i];
    L[n1]=inf,R[n2]=inf;
    i=0;
    int j=0,k;
    for(k=left;k<=right-1;k++){
        if(L[i]<=R[j]){
            s[k]=L[i];
            i++;
            
        }else{
            s[k]=R[j];
            j++;
            
        }
        count++;
    }
}

void mergeSort(int s[],int left,int right){
    if(left+1<right){
        int mid=(left+right)/2;
        mergeSort(s,left,mid);
        mergeSort(s,mid,right);
        merge(s,left,mid,right);
    }
}


int main(){
    int n;
    scanf("%d",&n);
    int s[n];
    int i;
    for(i=0;i<=n-1;i++)scanf("%d",&s[i]);
    
    mergeSort(s,0,n);
    
    for(i=0;i<=n-2;i++)printf("%d ",s[i]);
    printf("%d\n",s[n-1]);
    printf("%d\n",count);
    
    return 0;
}

Measured memory_bytes: 4504
N = int(input())
S = list(input())
vW = [0] * (N+1)
vE = [0] * (N+1)

for i in range(N):
    vW[i+1] += vW[i]
    if S[i] == "W":
        vW[i+1] += 1
    vE[i+1] += vE[i]
    if S[i] == "E":
        vE[i+1] += 1

ans = float("inf")
for i in range(N):
    ans = min(vW[i] + (vE[N]-vE[i+1]), ans)

print(ans)

Measured memory_bytes: 29260
from collections import OrderedDict
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
def factorize(m):
    d = []
    for i in range(1, int(m**0.5)+1):
        if m % i == 0:
            d.append(i)
            if i != m // i:
                d.append(m//i)
    return d
def main():
    N = int(input())
    A = list(map(int, input().split()))
    l = list(set(factorize(A[0]) + factorize(A[1])))
    l.sort(reverse=True)
    d = OrderedDict()
    for i in l:
    	d[i] = 0
    for i in A:
        for j in d:
            if i % j == 0:
                d[j] += 1
    m = 1
    for k in d:
        if d[k] >= N-1:
            print(k)
            return
    print(1)
main()


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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		String[] strlist = str.split(" ");
		long a = Long.parseLong(strlist[0]);
		long b = Long.parseLong(strlist[1]);
		long x = Long.parseLong(strlist[2]);

		long ax = a / x;
		long bx = b / x;
		long answer = 0;

		if(a % x == 0){
			answer = bx - ax + 1;
		}else{
			answer = bx - ax;
		}


		System.out.println(answer);

	}

}


Measured memory_bytes: 21332
function MainA(input) {
	input = input.split("\n");
	var n = input[0];
	var s = input[1];
	var r = 0;
	var b = 0;
	for(var i = 0; i < n; i++){
		if(s[i] == "R") r++;
		else b++;
	}
	var result = (r > b) ? "Yes" : "No";

	console.log('%s',result);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
MainA(require("fs").readFileSync("/dev/stdin", "utf8"));

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

void get_card_index(int &type, int &rank)
{
  char t;
  int r;
  cin >> t >> r;
  switch (t)
  {
    case 'S':
      type = 0;
      break;
    case 'H':
      type = 1;
      break;
    case 'C':
      type = 2;
      break;
    case 'D':
      type = 3;
      break;
  }
  rank = r - 1;
}

void print_card(int type, int rank)
{
  switch (type)
  {
    case 0:
      cout << 'S';
      break;
    case 1:
      cout << 'H';
      break;
    case 2:
      cout << 'C';
      break;
    case 3:
      cout << 'D';
      break;
  }
  cout << ' ' << rank + 1 << endl;
}

int main()
{
  vector<vector<bool>> cards(4, vector<bool>(13));
  int num;
  cin >> num;
  for (int i = 0; i < num; i++)
  {
    int type, rank;
    get_card_index(type, rank);
    cards.at(type).at(rank) = true;
  }
  for (int i = 0; i < cards.size(); i++)
  {
    for (int j = 0; j < cards.at(0).size(); j++)
    {
      if (!cards.at(i).at(j))
      {
        print_card(i, j);
      }
    }
  }
}



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

const double rad60 = 60 * M_PI / 180;

struct Point {
  double x, y;
};

void KochCurve(int n, Point p1, Point p2) {
  if (n == 0) return;
  Point s, t, u;
  s.x = (2.0 * p1.x + 1.0 * p2.x) / 3.0;
  s.y = (2.0 * p1.y + 1.0 * p2.y) / 3.0;
  t.x = (1.0 * p1.x + 2.0 * p2.x) / 3.0;
  t.y = (1.0 * p1.y + 2.0 * p2.y) / 3.0;
  u.x = (t.x - s.x) * cos(rad60) - (t.y - s.y) * sin(rad60) + s.x;
  u.y = (t.x - s.x) * sin(rad60) + (t.y - s.y) * cos(rad60) + s.y;
  KochCurve(n - 1, p1, s);
  std::printf("%.8f %.8f\n", s.x, s.y);
  KochCurve(n - 1, s,  u);
  std::printf("%.8f %.8f\n", u.x, u.y);
  KochCurve(n - 1, u,  t);
  std::printf("%.8f %.8f\n", t.x, t.y);
  KochCurve(n - 1, t, p2);
}

int main() {
  std::cin.tie(0);
  std::cin.sync_with_stdio(0);
  int n;
  std::cin >> n;
  Point p1 { 0, 0 };
  Point p2 { 100, 0 };
  std::printf("%.8f %.8f\n", p1.x, p1.y);
  KochCurve(n, p1, p2);
  std::printf("%.8f %.8f\n", p2.x, p2.y);
}



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

using namespace std;
using ll = long long;
#define MOD 1e9+7

int main(){
    int N;cin >> N;
    long double a = 0;
    for(int i = 1;i <= N;i++){
        if(i%2 == 1)a++;
    }
    cout<<setprecision(20)<<1.0*a/N<<endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  int a,b,c,s;
  cin >> b;
  for ( int i=0; i<N-1; ++i) {
    cin >> a;
    s += a*b;
    b +=a;
  }
 
  cout << s;
}

Measured memory_bytes: 256