akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#include <assert.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
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; }
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<vector<int>> G(N);
    for(int i=0; i<N-1; i++){
        int a,b;
        cin >> a >> b;
        a--;b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
    auto bfs = [&](int root){
        vector<int> dist(N,-1);
        queue<int> que;
        que.emplace(root);
        dist[root] = 0;
        while(que.size()){
            int v = que.front();
            que.pop();
            for(int nv : G[v]){
                if(dist[nv] != -1) continue;
                dist[nv] = dist[v] + 1;
                que.emplace(nv);
            }
        }
        int id;
        int mx = -1;
        for(int i=0; i<N; i++){
            if(chmax(mx,dist[i])){
                id = i;
            }
        }
        return P(id,mx);
    };
    P p = bfs(0);
    p = bfs(p.first);
    if(p.second%3 == 1){
        cout << "Second\n";
    }else{
        cout << "First\n";
    }
    return 0;
}

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

#define INF 0x3f3f3f3f
#define MOD 10000

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

string n;

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

	cin >> n;
	if (n.find('9') == -1) cout << "No" << endl;
	else cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 256
A=[list(map(int,input().split())) for _ in range(3)]
n=int(input())
for i in range(n):
    b=int(input())
    for a in A:
        for j in range(3):
            if a[j]==b:
                a[j] = 0
t_0=(0,0,0)
ans="No"
for a in A:
    if sum(a)==0:
        ans="Yes"
        break
if (A[0][0],A[1][1],A[2][2])==t_0:
    ans="Yes"
if (A[0][2],A[1][1],A[2][0])==t_0:
    ans="Yes"
for i in range(3):
    if (A[0][i],A[1][i],A[2][i])==t_0:
        ans="Yes"
        break
print(ans)

Measured memory_bytes: 3064
N,K=gets.split.map &:to_i
a=[0]+gets.split.map(&:to_i)
b=a.map{|i| [i,0].max}
N.times do |i|
  a[i+1] += a[i]
  b[i+1] += b[i]
end
p K.upto(N).map{|r|
  l = r-(K-1)
  b[l-1] + [0,a[r]-a[l-1]].max + b[N]-b[r]
}.max

Measured memory_bytes: 13556
#include<stdio.h>
#include<string.h>
char s[9];
char aa[9][9]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
int main(){
	scanf("%s",s);
	for(int i=0;i<7;i++)if(strcmp(aa[i],s)==0)printf("%d",7-i);
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;

typedef pair<int,int> P;


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

    map<int,int> A;
    map<int,int> B;
    REP(i,N/2){
        int v1,v2; cin >> v1 >> v2;
        A[v1] ++;
        B[v2] ++;
    }

    priority_queue<P> AA;
    priority_queue<P> BB;
    for(auto a: A){
        AA.push({a.second, a.first});
    }
    for(auto b: B){
        BB.push({b.second, b.first});
    }

    P top_a = AA.top(); AA.pop();
    P top_b = BB.top(); BB.pop();

    if(top_a.second != top_b.second){
        cout << N - top_a.first - top_b.first << endl;
    }else{
        if(!AA.empty() && !BB.empty()){
            if(top_a.first+BB.top().first > top_b.first+AA.top().first){
                cout << N - top_a.first - BB.top().first << endl;
            }else{
                cout << N - top_b.first - AA.top().first << endl;
            }
        }else if(AA.empty() && !BB.empty()){
            cout << N/2 - BB.top().first << endl;

        }else if(!AA.empty() && BB.empty()){
            cout << N/2 - AA.top().first << endl;
        }else{
            cout << N/2 << endl;
        }
    }

    return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    double n;
    cin >> n;
    double a[5];
    rep(i, 5) cin >> a[i];
    int ind = 0;
    rep(i, 5) if (a[i] <= a[ind]) ind = i;
    OP((ll)ceil(n / a[ind]) + 4);

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(long long i=(a);i<(b);++i)
#define per(i,a,b) for(long long i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
	ll k;
	cin>>k;
	cout << 50 << endl;
	vector<ll> v;
	rep(i,0,50){
		v.pb(49);
	}
	ll a = k/50;
	ll b = k%50;
	rep(i,0,50){
		v[i]+=a;
	}
	ll index = 0;
	rep(i,0,b){
		v[i]+=50;
		rep(j,0,50){
			if(i==j)continue;
			v[j]--;
		}
	}
	rep(i,0,v.sz){
		cout << v[i];
		if(i!=v.sz-1)cout << " ";
	}
	cout << endl;
	return 0;
}





Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
int ans=0;
int main(void){
	string s;
	cin>>s;
	int f1=0,f2=1,f3,i;
	if(s[0]=='A'&&s[1]>='a'&&s[1]<='z'&&s[s.size()-1]>='a'&&s[s.size()-1]<='z'){
	  for(i=2;i<s.size()-1;i++){
	    if(s[i]=='C')f1++;
	  }
	  for(i=2;i<s.size();i++){
	    if(s[i]!='C'&&(s[i]<'a'||s[i]>'z'))f2=0;
	  }
	}
	if(f1>=2)f1=0;
	f3=f1*f2;
	if(f3)cout<<"AC\n";
	else cout<<"WA\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
int DigitNum(int n)
{
    int res = 0;
    while (n > 0)
    {
        n /= 10;
        ++res;
    }
    return res;
}

void _main()
{
    int N;
    cin >> N;
    int ans = 0;
    rep(i, 1, N + 1)
    {
        if (DigitNum(i) % 2 == 1)
        {
            ++ans;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    char A,B;cin>>A>>B;
    cout<<((A==B)?"H":"D")<<endl;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
int main() {
    ios::sync_with_stdio(false);
    string a;
    cin>>a;
    if(a=="SUN")cout<<7;
    else if(a=="MON")cout<<6;
    else if(a=="TUE")cout<<5;
    else if(a=="WED")cout<<4;
    else if(a=="THU")cout<<3;
    else if(a=="FRI")cout<<2;
    else cout<<1;
    return  0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#include<iomanip>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,ll>P;

int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    if(n%2!=0)
    {
        cout<<"No";
    }
    else
    {
        string t=s.substr(0,n/2);
        if(t==s.substr(n/2,n/2))
        {
            cout<<"Yes";
        }
        else
        {
            cout<<"No";
        }
        
    }
    
}  

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

void fnInput(vector<int>& rvnSort)
{
  int nMaxSiz;
  
  cin >> nMaxSiz;
  rvnSort.resize(nMaxSiz);

  for (int i = 0; i < nMaxSiz; i++)
    cin >> rvnSort[i];
}

void fnBubbleSort(vector<int>& rvnSort, int& rnSortCnt)
{
  int nxMax = rvnSort.size() - 1;
  int nxStop = 0;
  while (nxStop != nxMax)
  {
    int nxMin = nxMax;
    for (int i = nxMax; i > nxStop; i--)
    {
      if (rvnSort[i] < rvnSort[i - 1])
      {
        swap(rvnSort[i], rvnSort[i - 1]);
        rnSortCnt++;
        nxMin = i;
      }
    }
    nxStop = nxMin;
  }
}

void fnOutput(const vector<int>& cnrvnSort, int nSortCnt)
{
  for (int i = 0; i < cnrvnSort.size(); i++)
  {
    if (i) cout << " ";
    cout << cnrvnSort[i];
  }
  cout << endl;
  cout << nSortCnt << endl;
}
    
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  int nSortCnt = 0;
  vector<int> vnSort;

  fnInput(vnSort);
  fnBubbleSort(vnSort, nSortCnt);
  fnOutput(vnSort, nSortCnt);

  return 0;
}



Measured memory_bytes: 3224
#include<bits/stdc++.h>
#include<string>
#include <algorithm>

using namespace std;

int main() {
  int n,k;
  cin >> n >> k;
  int v[n];
  
  for(int i=0;i<n;i++){
  cin  >> v[i];
  }
  
  sort(v, v+n, greater<int>());
  int sum=0;
  
  for(int i=0;i<k;i++){
    sum += v[i];
  }
  cout << sum;

}

Measured memory_bytes: 256
#include <iostream>
#include<math.h>

using namespace std;

int main() {
    int n,ans[100005],a[100005];
    cin>>n;
    for(int i=0;i<n;i++)
    cin>>a[i];
    ans[0] = 0;
    for(int i=1;i<n;i++){
        if(i==1)
        ans[i] = abs(a[1]-a[0]);
        else ans[i] = min(ans[i-1] + abs(a[i-1]-a[i]), ans[i-2] + abs(a[i-2]-a[i]));
    }
    
    cout<<ans[n-1];
}

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

namespace AtCoder
{
    class Program
    {
        static int t;
        static int a;

        static void Main(string[] args)
        {
            //[summary]B - Palace
            int n = int.Parse(Console.ReadLine());

            var line = ReadLine();
            t = line[0];
            a = line[1];

            var diffs = GetTemperatureDiffs(n);

            int result = diffs.OrderBy(x => x.Value).First().Key;
            Console.WriteLine(result);
        }

        static Dictionary<int,double> GetTemperatureDiffs(int n)
        {
            var line = ReadLine();
            var dic = new Dictionary<int, double>();

            for(int i = 0; i < n; i++)
            {
                int height = line[i];
                double temperature = CalcTemperature(height);
                double diff = Math.Abs(a - temperature);
                dic.Add(i + 1, diff);
            }

            return dic;
        }

        static double CalcTemperature(int height)
        {
            return t - height * 0.006;
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine().TrimEnd();
            var array = line.Split(' ');
            var numbers = new List<int>();

            foreach (var s in array)
            {
                int num = int.Parse(s);
                numbers.Add(num);
            }

            return numbers;
        }
    }
}

Measured memory_bytes: 13536
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        BigInteger a= sc.nextBigInteger();
        BigInteger b=sc.nextBigInteger();
        BigInteger c= a.mod(b);
        BigInteger d= b.subtract(c);
        System.out.println((c.min(d)));

    }
}


Measured memory_bytes: 22100
import java.util.*;
class Main{
    public static void main(String argv[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int D = sc.nextInt();
        int[][] X = new int[N][D];

        for(int i=0;i<N;i++){
            for(int j=0;j<D;j++){
                X[i][j] = sc.nextInt();
            }
        }

        int count = 0;
        for(int i=0;i<N;i++){
            for(int j=i+1;j<N;j++){
                Double len = 0D;
                for(int k=0;k<D;k++){
                    len += (Double) Math.pow(X[i][k] - X[j][k], 2);
                }
                int len2 = (int)Math.sqrt(len);
                len = Math.sqrt(len);
                if((double)len2 == len)count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 21844
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    static int H, W, K;
    static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        FastScanner fc = new FastScanner(System.in);
        H = fc.nextInt();
        W = fc.nextInt();
        K = fc.nextInt();
        System.out.println(solve());
    }

    static int solve() {
        if( W == 1 ) return 1;

        long[][] dp = new long[H+1][W];
        dp[0][0] = 1;
        // System.out.println( Arrays.toString(dp[0]) );

        for (int h = 1; h <= H; h++) {
            for (int s = 0; s < 1 << (W-1); s++) {
                if( !isValid(s) ) continue;

                for (int w = 0; w < W; w++) {
                    // w = 1 なら b1=0, b2=1
                    int b1 = w-1;
                    int b2 = w;
                    if( (s & 1 << b1) > 0 ) {
                        dp[h][w] = (dp[h-1][w-1] + dp[h][w]) % MOD;

                    } else if( (s & 1 << b2) > 0 ) {
                        dp[h][w] = (dp[h-1][w+1] + dp[h][w]) % MOD;

                    } else {
                        dp[h][w] = (dp[h-1][w] + dp[h][w]) % MOD;
                    }
                }
            }
            // System.out.println( Arrays.toString(dp[h]) );
        }
        return (int)dp[H][K-1];
    }

    static boolean isValid(int s) {
        // 立ってるbitが隣接したらダメ
        return (s & s << 1) == 0;
    }

    @SuppressWarnings("unused")
    static class FastScanner {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 23124
s = open(0).read()
s = s.lower()
count = [0 for i in range(26)]
for i in range(len(s)):
    m = ord(s[i]) - ord('a')
    if m >= 0 and m < 26:
        count[m] += 1 

for i in range(26):
    print(chr(i + ord('a')),":",count[i])


Measured memory_bytes: 5580
def slove():
    import sys
    input = sys.stdin.readline
    s = int(input().rstrip('\n'))
    x1 = y1 = x2 = y2 = x3 = y3 = 0
    x2 = 1
    y2 = 10 ** 9
    x3 = (s + y2 - 1) // y2
    y3 = x3 * y2 - s
    print(x1, y1, x2, y2, x3, y3)


if __name__ == '__main__':
    slove()


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

#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);

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

    int arr[n+1]={};
    
    //fill_n(arr, n+1, 0);

    for(int i=1;i<n;i++) {
        int n;
        cin>>n;

        arr[n]++;
    }

    for(int i=1;i<n+1;i++) {
        cout<<arr[i]<<endl;
    }

}




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

public class Main {

	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			String str = br.readLine();
			String[] arr = str.split(" ");
			int x = Integer.parseInt(arr[0]);
			int y = Integer.parseInt(arr[1]);
			int z = x*y;
			int a = x+x+y+y;
		
			System.out.println(z + " " + a);
		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}

	}
}

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

int main() {
    long n, a, result;
    vector<long> monsters;
    cin >> n;
    for (long i=0; i<n; i++) {
        cin >> a;
        monsters.push_back(a);
    }
    result = monsters[0];
    for (long i=1; i<n; i++) {
        result = __gcd(result,monsters[i]);
    }
    cout << result;
    return 0;
}

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

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

int main()
{
    int N, dig, sum = 1, res = 0;
    int d[110];
    for (int i = 0; i < 110; i++)
        d[i] = 0;

    cin >> N;
    for (int i = 0; i < N; i++)
        cin >> d[i];
    sort(d, d + N, greater<int>());

    for (int i = 1; i < N; i++)
    {
        if (d[i] != d[i - 1])
            sum++;
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
//                        Bismillahir Rahmanir Rahim
//ALGO:
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define FILL(a, x) memset(a, x, sizeof(a))
#define ll long long
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define INF INT_MAX
#define mx 1000010
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_multiset tree<pair<int, int>, null_type,less<pair<int, int> >, rb_tree_tag,tree_order_statistics_node_update>
*/
const double Pi=acos(-1);
using namespace std;
int debug=01;
ll dp[100010], h[100010];
int k=2, n;
ll solve(int i){
    if(i==n) return 0;
    if(~dp[i]) return dp[i];
    ll ret=999999999999999999;
    for(int j=i+1; j<=min(n, i+k); j++) ret=min(ret, solve(j)+abs(h[i]-h[j]));
    return dp[i]= ret;
}
int main() {
    cin>>n>>k;
    FILL(dp, -1);
    for(int i=1; i<=n; i++)cin>>h[i];
    cout<<solve(1);
}



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

int main(){
  int n; cin >> n;
  vector<int> t(n);
  for(int i=0;i<n;i++) cin >> t.at(i);
  int m; cin >> m;
  vector<int> p(2*m);
  for(int i=0;i<2*m;i++) cin >> p.at(i);
  
   int total=0;
  for(int i=0;i<n;i++){
    total += t.at(i);
  }
  for(int i=0;i<m;i++){
    total = total-t.at(p.at(2*i)-1) + p.at(2*i+1);
    cout << total << endl;
    total = total-p.at(2*i+1) +t.at(p.at(2*i)-1);
  }
}

Measured memory_bytes: 256
n, m = map(int, input().split())
c = list(map(int, input().split()))

dp = [[10**8]*(n+1) for i in range(m+1)]
dp[0][0] = 0
for i in range(m):
    for j in range(n+1):
        dp[i+1][j] = min(dp[i][j], dp[i+1][j])
        if j + c[i] <= n:
            dp[i+1][j+c[i]] = min(dp[i+1][j]+1, dp[i+1][j+c[i]])

print(dp[m][n])



Measured memory_bytes: 43780
#include <bits/stdc++.h>
using namespace std;
#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL);

// int64_t dis(int64_t x, int64_t y, int64_t n) {
//   int64_t len = min(max(y - x, x - y), n - max(y - x, x - y));
//   return len;
// }

int main() {
  FAST;
  int64_t N, X, Y, distance;
  cin >> N >> X >> Y;
  vector<int64_t> A(N, 0);
  for (int64_t i = 1; i < N + 1; i++) {
    for (int64_t j = i + 1; j < N + 1; j++) {
      // distance = dis(i, j, N);
      // distance = min(distance, dis(i, X, N) + 1 + dis(Y, j, N));
      // distance = min(distance, dis(i, Y, N) + 1 + dis(X, j, N));
      distance = j - i;
      distance = min(distance, max(i - X, X - i) + 1 + max(j - Y, Y - j));
      A.at(distance)++;
    }
  }
  for (int64_t i = 1; i < N; i++) {
    cout << A.at(i) << endl;
  }
}

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

int main() {
  vector<int> vec(5);
  for (int i = 0; i < 5; i++) cin >> vec.at(i);
  int N;
  cin >> N;

  if (vec.at(4) - vec.at(0) <= N) cout << "Yay!" << endl;
  else cout << ":(" << endl;
}

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin>>s;
  if(s=="ABC"){
    cout<<"ARC"<<endl;
  }else if("ARC"){
    cout<<"ABC"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3596
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>

inline void read(int &T) {
	int x=0;bool f=0;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=!f;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	T=f?-x:x;
}

std::string s;

int main() {
	std::cin>>s;
	for(int i=0;i<3;++i) {
		std::cout<<s[i];
	}
	return 0;
}

Measured memory_bytes: 3616
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M=sc.nextInt();
        float sum=0;
        Integer[] arr=new Integer[N];
        for(int i=0;i<N;i++){
            arr[i]=sc.nextInt();
            sum=sum+arr[i];
        }
        int flag=1;
//        System.out.println(sum);
        Arrays.sort(arr, Collections.reverseOrder());
        Float l=(sum/(4*M));
//        System.out.println(l);

        for (int i=0;i<M;i++){
//            System.out.println(arr[i]);
            if(arr[i] < l){
                flag=0;
                break;
            }
        }
        if (flag==1)
            System.out.println("Yes");
        else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 25172
from collections import Counter

N, *A = map(int, open(0).read().split())

m = max(A) + 1
ok = [True] * m
ctr = Counter(A)
ans = 0
for a in sorted(A):
    if ok[a] and ctr[a] == 1:
        ans += 1
        
    for j in range(2 * a, m, a):
        ok[j] = False
            
print(ans)


Measured memory_bytes: 133204
#include <bits/stdc++.h> //library
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //for-loop (from 0)
#define reps(i,n) for(int i = 1; i <= (int)(n); i++) //for-loop (from 1)
#define all(x) (x).begin(),(x).end() //start-to-end iteration, mainly in upper_bound, lower_bound
#define SZ(x) ((int)(x).size()) //unsigned to signed

using namespace std;
using ll = long long; //long long
ll M = 1000000000 + 7;
const ll INF = 1LL << 60;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; } //compare a,b and replace by greater
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; } //compare a,b and replace by smaller
ll qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; } //power
ll qp(int a, ll b, ll Mod = M) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%Mod; a = 1ll * a*a%Mod; } while (b >>= 1); return ans; } //power(mod)
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; } //gcd
int dx[4] = { 1,0,-1,0 }; //path
int dy[4] = { 0,1,0,-1 }; //path
ll RS(ll N, ll P, ll Mod = M) { if (P == 0)return 1; else if (P % 2 == 0) { ll sq = RS(N, P / 2, Mod); return sq*sq%Mod; } else { return N*RS(N, P - 1, Mod) % Mod; } } //power(mod)(repeat-square,fast)
ll nPr(ll n, ll r, ll Mod = M) { ll ans = 1; rep(i, r) { ans = ans * (n - i) % Mod; } return ans; } //permutation
ll nCr(ll n, ll r, ll Mod = M) { ll bunbo = 1; ll bunshi = 1; rep(i, r) { bunbo = bunbo * (i + 1) % Mod; bunshi = bunshi * (n - i) % Mod; } return bunshi * RS(bunbo, Mod - 2, Mod) % Mod; } //combination

int take_difference(int &A, int &B){
  int x = A - B;
  int res;
  if (x < 0){
    B -= A;
    res = A;
    A = 0;
  }
  else{
    A -= B;
    res = B;
    B = 0;
  }
  return res;
}

int main(void) {
  int N; cin >> N;
  vector<int> A(N+1),B(N);
  rep(i,N+1) cin >> A[i];
  rep(i,N) cin >> B[i];
  ll res = 0;
  
  rep(i,N){
    res += take_difference(A[i],B[i]);
    res += take_difference(A[i+1],B[i]);
  }

  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int i,j,n,wt;
  cin>>n>>wt;
   int w[n+1],v[n+1];
  long long int dp[n+1][wt+1];
  for(i=0;i<n;i++)
    cin>>w[i]>>v[i];
  for(i=0;i<n;i++)
  	dp[i][0]=0;
  for(i=0;i<n;i++)
  {
    for(j=1;j<=wt;j++)
    {
      if(i==0)
      {
        if(j>=w[i])
          dp[i][j]=v[i];
        else
          dp[i][j]=0;
      }
      else
      {
      if(j-w[i]<0)
        dp[i][j]=dp[i-1][j];
      else
      	dp[i][j]=max(v[i]+dp[i-1][j-w[i]],dp[i-1][j]);
      }
    }
  }
  cout<<dp[n-1][wt];
}

Measured memory_bytes: 78336
def cnv(i0, j0):
    global h, w, s
    if s[i0][j0] == '#':
        return '#'
    else:
        cnt = 0
        for dxy in [(0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1), (-1, 0), (-1, 1)]:
            i = i0 + dxy[1]
            j = j0 + dxy[0]
            if 0 <= i < h and 0 <= j < w and s[i][j] == '#':
                cnt += 1
        return str(cnt)


h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]

for i in range(h):
    for j in range(w):
        s[i][j] = cnv(i, j)

for si in s:
    print(''.join(si))

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

using namespace std;

int main(){
	string s, t;
	cin >> s >> t;

	vector<vector<int> > DP(s.length() + 1, vector<int> (t.length() + 1));
	for(int s_index = 1; s_index < s.length() + 1; s_index++)
		for(int t_index = 1; t_index < t.length() + 1; t_index++)
			if(s[s_index - 1] == t[t_index - 1]) DP[s_index][t_index] = DP[s_index - 1][t_index - 1] + 1;
			else DP[s_index][t_index] = max(DP[s_index - 1][t_index], DP[s_index][t_index - 1]);

	int index = DP[s.length()][t.length()];
	char result[index + 1];
	  
	int row = s.length(), col = t.length(); 
	while((row > 0) && (col > 0))
	    if(s[row - 1] == t[col - 1]){
	        result[index - 1] = s[row - 1];
	        row--;
	        col--;
	        index--;
	    } else if(DP[row - 1][col] > DP[row][col - 1]) row--; 
	    else col--;

	for(int index = 0; index < DP[s.length()][t.length()]; index++)
		cout << result[index];

	return 0;
}


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

using namespace std;

int W, H;
bool reached[50][50][50][50];
bool wall[2][50][50];
int gx[2], gy[2];

typedef pair<int, int> P;

struct Node {
	int x1, y1, x2, y2;
};

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

bool inRange(int x, int y) {
	return 0 <= x && x < W && 0 <= y && y < H;
}
bool isGoal(int id, int x, int y) {
	return x == gx[id] && y == gy[id];
}
bool isWall(int id, int x, int y) {
	if ( !inRange(x, y) ) return true;
	return wall[id][y][x];
}
P go(int id, int x, int y, int d) {
	int nx = x + dx[d], ny = y + dy[d];
	if ( isWall(id, nx, ny) ) return P(x, y);
	return P(nx, ny);
}

int main() {
	while ( cin >> W >> H, W || H ) {
		fill(&reached[0][0][0][0], &reached[0][0][0][0]+50*50*50*50, false);
		int sx[2], sy[2];
		for (int y = 0; y < H; ++y) {
			for (int i = 0; i < 2; ++i) {
				string str; cin >> str;
				for (int x = 0; x < W; ++x) {
					switch (str[x]) {
						case '.': wall[i][y][x] = false; break;
						case '#': wall[i][y][x] = true; break;
						case '%': wall[i][y][x] = false; gx[i] = x, gy[i] = y; break;
						case 'R':
						case 'L': wall[i][y][x] = false; sx[i] = x, sy[i] = y; break;
					}
				}
			}
		}
		queue<Node> Q; Q.push((Node){sx[0], sy[0], sx[1], sy[1]});
		reached[sx[0]][sy[0]][sx[1]][sy[1]] = true;
		while ( !Q.empty() ) {
			Node node = Q.front(); Q.pop();
			int x1 = node.x1, y1 = node.y1;
			int x2 = node.x2, y2 = node.y2;
			if ( !isGoal(0, x1, y1) && !isGoal(1, x2, y2) ) {
				for (int d = 0; d < 4; ++d) {
					int d1 = d, d2 = d % 2 == 0 ? d : (d+2)%4;
					P p1 = go(0, x1, y1, d1);
					P p2 = go(1, x2, y2, d2);
					int nx1 = p1.first, ny1 = p1.second;
					int nx2 = p2.first, ny2 = p2.second;
					if ( !reached[nx1][ny1][nx2][ny2] ) {
						reached[nx1][ny1][nx2][ny2] = true;
						Q.push((Node){nx1, ny1, nx2, ny2});
					}
				}
			}
		}
		if (reached[gx[0]][gy[0]][gx[1]][gy[1]]) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
}

Measured memory_bytes: 8256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
	ll a,b;
	cin>>a>>b;
	if(b%2==0){
		ll z=(a/b)*(a/b)*(a/b);
		if(a%b>=b/2){
			cout<<z+((a/b)+1)*((a/b)+1)*((a/b)+1);
		}
		else{
			cout<<2*z;
		}
	}
	else{
		cout<<(a/b)*(a/b)*(a/b);
	}
}

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

using namespace std;
using ll = long long;

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

  int n;
  ll k;
  cin >> n >> k;
  vector<int> p(n);
  vector<ll> c(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
    p[i]--;
  }
  for (int i = 0; i < n; i++)
    cin >> c[i];

  const ll inf = 1e9;

  // loop_cnt[i] := iからスタートしてループするのにかかる回数
  // loop_score[i].size() - 1 で求められるから不要か
  vector<int> loop_cnt(n);
  // loop_cnt[i][j] := iからスタートしてj回移動した時に得られるスコア
  // vector<vector<ll>> loop_score(n, vector<ll>(n + 1, -inf));
  vector<vector<ll>> loop_score(n);
  for (int i = 0; i < n; i++) {
    int cur = i;
    ll sum = 0;
    loop_score[i].push_back(-inf);
    for (int j = 1;; j++) {
      cur = p[cur];
      sum += c[cur];
      loop_score[i].push_back(sum);
      if (cur == i) {
        loop_cnt[i] = j;
        break;
      }
    }
  }

  ll ans = *max_element(c.begin(), c.end());

  for (int i = 0; i < n; i++) {
    ll l = loop_cnt[i];
    // cerr << l << endl;

    auto score = loop_score[i];

    if (k <= l) {
      // 一周出来ない
      ans = max(ans, *max_element(score.begin(), score.begin() + k + 1));
    } else {
      ll m = k / l;
      ans = max({
          ans,
          // 一周する価値が無い
          max(ans, *max_element(score.begin(), score.end())),
          // (m-1)周+最大まで
          ans = max(ans, score[l] * (m - 1) +
                             *max_element(score.begin(), score.end())),
          // m周+最大まで
          ans = max(ans, score[l] * m +
                             max(0ll, *max_element(score.begin(),
                                                   score.begin() + k % l + 1))),
      });
    }
    // }
    // else if (score[l] < 0) {
    //   // 一周する価値が無い時
    //   ans = max(ans, *max_element(score.begin(), score.end()));
    // }
    // else {
    //   ll m = k / l;
    //   ans = max(ans,
    //             score[l] * (m - 1) + *max_element(score.begin(),
    //             score.end()));
    //   ans = max(ans, score[l] * m +
    //                      max(0ll, *max_element(score.begin(),
    //                                            score.begin() + k % l +
    //                                            1)));
    // }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 218852
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N;
    string S;
    cin >> N >> S;
    int res = 0;
    for (int i = 1; i < N; i++) {
        if (S[i] == 'E') res++;
    }
    int ans = res;
    for (int i = 1; i < N; i++) {
        if (S[i] == 'E') {
            res--;
        }
        if (S[i-1] == 'W') {
            res++;
        }
        ans = min(ans, res);
    }
    cout << ans << endl;
}

Measured memory_bytes: 900
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1000000007;
const ll MOD = 1000000000000000001;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);


ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b){
  ll r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


ll LCM(ll a,ll b){
  ll c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}



/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n;
  string s;
  cin>>n>>s;
  rep(i,s.size()){
    if(s[i]+n>'Z'){
      s[i]=s[i]+n-26;
    }else{
      s[i]=s[i]+n;
    }
  }
  cout<<s<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define LL long long
int st[20],top;
int main(){
	LL n;
	int i;
	scanf("%lld",&n);
	while(n){
		st[++top]=(n-1)%26;
		n--;
		n/=26;
	}
	for(i=top;i>=1;i--)printf("%c",'a'+st[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 1636
#include<bits/stdc++.h>
using namespace std;
#define int long  long
#define double long double
int t,n;
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    t=1;
  //  cin>>t;
    while(t--)
    {
        cin>>n;
        cout<<((ceil(n/1000.0)-n/1000.0)*1000);
    }
}


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


main()
{
    int h,n; cin>>h>>n;
    while(n--)
    {
        int a; cin>>a;
        h-=a;
    }
    if(h>0) cout << "No" << "\n";
    else cout << "Yes" << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int t;
long long l;
long long ksm(long long a,long long b,long long c)
{
    long long res=1;
    while(b)
    {
        if(b&1)
            res=(res*a)%c;
        a=(a*a)%c;
        b>>=1;
    }
    return res;
}
long long phi(long long x)
{
    long long res=x;
    for(int i=2;i*i<=x;i++)
    {
        if(x%i==0)
        {
            res=res/i*(i-1);
            while(x%i==0)
                x/=i;
        }
    }
    if(x>1)
        res=res/x*(x-1);
    return res;
}
int main()
{
    int kase=0;
    cin>>l;
    long long mod=l/__gcd(7ll,l)*9ll;
    long long p=phi(mod);
    long long res=1e18;
    for(long long x=1;x*x<=p;x++)
    {
        if(p%x!=0) continue;
        if(ksm(10,x,mod)==1) res=min(res,x);
        if(ksm(10,p/x,mod)==1) res=min(res,p/x);
    }
    if(res==1e18)cout<<"-1"<<endl;
        else cout<<res<<endl;
}

Measured memory_bytes: 3632
#include <string>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

const int N=1e4+5;

int n,pa[N],pb[N],ta,tb,pos[N];
char st[N];
string an[N];

int main() {
	scanf("%d",&n);
	scanf("%s",st+1);
	fo(i,1,n<<1)
		if (st[i]=='a') pa[++ta]=i,pos[i]=ta;
		else pb[++tb]=i,pos[i]=tb;
	fd(i,n,1) {
		if (pa[i]<pb[i]) {
			int k=i;
			fo(j,pa[i]+1,pb[i]) k=max(k,pos[j]);
			an[i]="ab"+an[k+1];
		} else {
			int k=i;
			for(;k<n&&pb[k+1]<pa[k];k++);
			fo(j,pb[i],n<<1) if (pos[j]>=i&&pos[j]<=k) an[i]=an[i]+st[j];
			an[i]=an[i]+an[k+1];
		}
		an[i]=max(an[i],an[i+1]);
	}
	cout<<an[1]<<endl;
	return 0;
}

Measured memory_bytes: 10624
n = gets.to_i
p = Array.new(n) { gets.chomp.split.map(&:to_f) }
d = 0.0
0.step(n - 2) do |i|
  (i + 1).step(n - 1) do |j|
    xi, yi = p[i]
    xj, yj = p[j]
    d += Math::sqrt((xj - xi) ** 2 + (yj - yi) ** 2)
  end
end
puts "%.7f" % [d * 2.0 / n]

Measured memory_bytes: 1788
#include <algorithm>
#include <iostream>
#include <queue>
#include <queue>
#include <stdio.h>
#include <string>

using namespace std;

void solve(int N, int M) {
  long long ans = 0;
  priority_queue<pair<int, int>> que;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    que.push(make_pair(a, 1));
  }
  for (int i = 0; i < M; i++) {
    int b, c;
    cin >> b >> c;
    que.push(make_pair(c, b));
  }
  for (int i = 0; i < N; i++) {
    auto x = que.top();
    que.pop();
    ans += x.first;
    if (x.second > 1) {
      x.second -= 1;
      que.push(x);
    }
  }
  printf("%lld\n", ans);
}

int main() {
  int N, M;
  scanf("%d %d", &N, &M);
  solve(N, M);
  return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
  int n;
  string s[3];
  cin >> s[0] >> s[1] >> s[2];
  cout <<'A' << char(toupper(s[1][0])) << 'C'<< endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

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

int intceil(int a, int b) {
    return (a + (b - 1)) / b;
}

signed main() {
    cin >> N >> A >> B;
    vi h(N);
    cin >> h;
    int ok = 1e9 + 1;
    int ng = -1;

    while (abs(ok - ng) > 1) {
        int n = 0;
        int mid = (ok + ng) / 2;
        REP(i, N) {
            int tmp = h[i] - mid * B;
            if (tmp > 0) {
                n += intceil(tmp, A - B);
            }
        }
        dump(n, mid);
        if (n <= mid) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    cout << ok << endl;
}

Measured memory_bytes: 3976
// B - String Rotation
#include <bits/stdc++.h>
using namespace std;

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

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

class Program
{
    static void Main()
    {
        var line = Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).ToArray();
        var N = line[0];
        var T = line[1];
        var t = Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).ToArray();
        var allTime = 0L;
        var beforeTime = t[0];
        for (int i=1;i<N;++i)
        {
            var sa = t[i]-beforeTime;
            if (T < sa) allTime += T;
            else allTime += sa;
            beforeTime = t[i];
        }
        allTime += T;
        Console.WriteLine(allTime);
    }
}

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

int main() {
	int n,d[3];
	cin>>n;
	for(int i=0; i<n; i++){
		cin>>d[0]>>d[1]>>d[2];
		sort(d,d+3);
		if(d[0]*d[0]+d[1]*d[1] == d[2]*d[2]){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1168
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int m=sc.nextInt();
			int t=sc.nextInt();
			int p=sc.nextInt();
			int r=sc.nextInt();
			if((m==0&&t==0)&&(p==0&&r==0)) break;
			int[][] data = new int[3+p][t];
			for(int i=0;i<r;++i){
				int mi=sc.nextInt();
				int ti=sc.nextInt();
				int pi=sc.nextInt();
				int ji=sc.nextInt();
				if(ji==0){
					data[0][ti-1]++;
					data[1][ti-1]+=mi+20*data[2+pi][ti-1];
				} else {
					data[2+pi][ti-1]++;
				}
			}
			int item=0;
			while(true){
				int max=0,time=0,count=0;
				if(item==t) break;
				for(int j=0;j<t;++j){
					if(max<data[0][j]&&data[2][j]==0){
						max=data[0][j]; time=data[1][j]; count=1;
					} else if(max==data[0][j]&&data[2][j]==0){
						if(data[1][j]<time){
							time=data[1][j]; count=1;
						} else if(data[1][j]==time){
							count++;
						}
					}
				}
				for(int i=0;i<count;++i){
					for(int j=t-1;j>=0;--j){
						if((data[0][j]==max && data[1][j]==time)&&data[2][j]==0){
							System.out.print(j+1);
							data[2][j]=1;
							j=-1;
						}
					}
					if(item+1!=t){
						if(count==1||i==count-1&&(item+count!=t)){ System.out.print(","); }
						else if(i<count-1){ System.out.print("="); }
					}
				}
				item+=count;
			}
			System.out.println();
		}
	}
}



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

void solve(long long N, long long A, long long B){
  cout << max(0ll, (((N-2)*B)-((N-2)*A))+1) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
  scanf("%lld",&N);
  long long A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
    solve(N, A, B);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <utility>
using namespace std;
typedef long long int lli;
typedef pair<int, int> pii;
typedef pair<lli, lli> pll;
const lli inf = 1e18;

int main(){
	int n,m;
	cin >> n >> m;
	vector<int> a(n);
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	vector<pll> cb(m);
	for(int i=0; i<m; i++){
		cin >> cb[i].second >> cb[i].first;
	}
	for(int i=0; i<n; i++){
		cb.emplace_back(a[i], 1);
	}
	sort(cb.begin(), cb.end(), greater<pll>());
	lli sum = 0;
	for(auto e: cb){
		if(e.second >= n){
			sum += e.first*n;
			break;
		}else{
			sum += e.first*e.second;
			n -= e.second;
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 7300
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP1(i, n) for (int i = 1; i < (n); i++)
#define CIN(A) int A; cin >> A;
#define CIN2(A, B) int A, B; cin >> A >> B;
#define CIN3(A, B, C) int A, B, C; cin >> A >> B >> C;
#define CINV(A, N) vector<int> A; REP(i, N) { int a; cin >> a; A.emplace_back(a); }
#define ANS(ans) cout << (ans) << endl

bool pair_greater(pair<int, int> p, pair<int, int> q)
{
  return p.first > q.first;
}

int
main()
{
  CIN2(N, M);

  if (M <= N) { ANS(0); return 0; }
  
  vector<int> X, X0;
  REP(i, M) { int a; cin >> a; X.emplace_back(a); X0.emplace_back(a); }

  sort(X.begin(), X.end());	// zahyo
  
  if (N == 1) { ANS(X.at(X.size() - 1) - X.at(0)); return 0; }

  vector<pair<int, int>> L;	// kankaku
  REP(i, M - 1) { L.emplace_back(make_pair(X.at(i + 1) - X.at(i), i)); }
  sort(L.begin(), L.end(), pair_greater);

  vector<int> V;		// kugiri
  REP(i, N - 1) V.emplace_back(L.at(i).second);
  sort(V.begin(), V.end());

  ull ans = 0;
  ans += X.at(V.at(0)) - X.at(0);
  REP(i, V.size() - 1) {
    ans += X.at(V.at(i + 1)) - X.at(V.at(i) + 1);
  }
  ans += X.at(X.size() - 1) - X.at(V.at(V.size() - 1) + 1);

  ANS(ans);

  return 0;
}


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

using ll = long long;

#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=b-1;i>=a;i--)

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

int r,n;
int xl[25], xr[25], h[21];
int he[45];

int main(){
    while(true){
        cin>>r>>n;
        if(r+n==0)break;
        REP(i,n)cin>>xl[i]>>xr[i]>>h[i];
        const int C = 21;
        fill(he,he+45,0);
        REP(i,n)FOR(x,C+xl[i],C+xr[i])he[x]=max(he[x],h[i]);
        double ans = 1e25;
        REP(i,45){
            int x = i-C;
            if(x<0)x++;
            x = abs(x);
            if(x>=r)continue;
            double y = sqrt(r*r-x*x);
            ans = min(ans, he[i]+r-y);
        }
        printf("%.9f\n",ans);
    }
    return 0;
}



Measured memory_bytes: 3148