akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(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;}
const int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;



int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
    string s,t;
    cin>>s>>t;
    vvi is(26);
    rep(i,s.size())is[s[i]-'a'].push_back(i);
    rep(i,s.size())is[s[i]-'a'].push_back(i+s.size());
    
    ll ans=0;
    int p=0;

    for(int i=0;i<t.size();i++){
        if(is[t[i]-'a'].size()==0){
            cout<<-1<<endl;
            return 0;
        }
        p=*lower_bound(is[t[i]-'a'].begin(),is[t[i]-'a'].end(),p)+1;
        if(p>=(int)s.size()){
            p-=(int)s.size();
            ans+=(int)s.size();
        }
    }
    ans+=p;
    fin(ans);
    
    
//////////////////////////////////////////////////////
return 0;}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll r, D, x; cin >> r >> D >> x;
    rep(i, 10){
        x = r * x - D;
        cout << x << endl;
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


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

const int maxn = int(1e5)+5;

int A[maxn];

int main(void)
{
	int n, k, v = 0;
	scanf("%d%d", &n, &k);
	for(int i = 0;i < n;i++)
	{
		scanf("%d", &A[i]);
		v = __gcd(v, A[i]);
	}

	for(int i = 0;i < n;i++)
	{
		if(A[i]-k >= 0 && (A[i]-k)%v == 0)
		{
			printf("POSSIBLE\n");
			exit(0);
		}
	}
	printf("IMPOSSIBLE\n");
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
const long long INF = 1LL << 60;
const int MOD = 1000000007;
signed main(void){
    int n; cin>>n;
    vector <vector<int>> A(n,vector <int>(n));
    rep(i,n)rep(j,n) cin>>A[i][j];
    vector <vector<int>> d(n,vector <int>(n));
    vector <vector<int>> edge(n,vector <int>(n));
    rep(i,n)for(int j=i;j<n;j++){
        if(A[i][j]==0) continue;
        d[i][j] = d[j][i] = A[i][j];
        edge[i][j] = A[i][j];
    }
    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if(i==k||j==k) continue;
                if(d[i][j]== d[i][k] + d[k][j]){
                    edge[i][j] = 0;
                }else if(d[i][j]>d[i][k]+d[k][j]) {cout<<-1<<endl; return 0;}
            }
        }
    }
    itn ans = 0;
    rep(i,n)rep(j,n) ans += edge[i][j];
    cout<<ans<<endl;
}


Measured memory_bytes: 2432
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int T = 0, X = 0;
    double t = 0, x = 0, m = 0;
    scanf("%d %d", &T, &X);
    t = T;
    x = X;
    m = t / x;
    printf("%f\n", m);
    return 0;
}


Measured memory_bytes: 128
#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 pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int a=0,b=0;
string s;

int main(){
	cin >> s;
	
	cout << s.substr(0,4) << " " << s.substr(4,8) << endl;
	return 0;
}


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

int main(void){
	double high=0,low=0,x;
	while(scanf("%lf",&x)!=EOF){
		if(high<x)high=x;
		if(low==0 || x<low)low=x;
	}
	printf("%lf\n",high-low);
	return 0;
}

Measured memory_bytes: 648
S = list(input())

aa = int(S[0]+S[1])
bb = int(S[2]+S[3])

yymm = 0;
mmyy = 0;

if(1<=aa and aa<=12):
    yymm = 1;

if(1<=bb and bb<=12):
    mmyy = 2;

if(yymm + mmyy == 3):
    print("AMBIGUOUS")
elif(yymm+mmyy == 2):
    print("YYMM")
elif(yymm+mmyy == 1):
    print("MMYY")
elif(yymm+mmyy == 0):
    print("NA")



Measured memory_bytes: 3064
Option Explicit On

Module Module1

    Sub Main()

        Dim tmp As String() = Split(Console.ReadLine(), " ")
        Dim A As Integer = CInt(tmp(0))
        Dim B As Integer = CInt(tmp(1))
        Dim H As Integer = CInt(tmp(2))
        Dim M As Integer = CInt(tmp(3))

        Dim jkaku As Double = H * 30 + M * 0.5
        Dim fkaku As Double = M * 6
        Dim kaku As Double

        If jkaku - fkaku <= 180 Then
            kaku = Math.Abs(jkaku - fkaku)
        Else
            kaku = 360 - Math.Abs(jkaku - fkaku)
        End If

        Dim yogen As Double = Math.Sqrt(A ^ 2 + B ^ 2 - 2 * A * B * Math.Cos(kaku * Math.PI / 180))

        Console.WriteLine(yogen)

    End Sub

End Module



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

const int MAXN = 300010;
const ll INF = 4e18;

int N;
int A[MAXN];

ll pref[MAXN], suff[MAXN];

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

	priority_queue<int> que;
	ll sum = 0;

	// maximize first half
	for (int i = 0; i < 3*N; i++) {
		que.push(-A[i]);
		sum += A[i];
		if (que.size() > size_t(N)) {
			sum -= -que.top();
			que.pop();
		}
		pref[i+1] = sum;
	}

	while (!que.empty()) que.pop();
	sum = 0;
	
	// minimize second half
	for (int i = 3*N-1; i >= 0; i--) {
		que.push(A[i]);
		sum += A[i];
		if (que.size() > size_t(N)) {
			sum -= que.top();
			que.pop();
		}
		suff[i+1] = sum;
	}

	ll ans = -INF;
	for (int i = N; i <= 2*N; i++) {
		ans = max(ans, pref[i]-suff[i+1]);
	}

	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 6648
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	H, W, h, w = getlist()
	L = [[1] * W for i in range(H)]
	if h * w != 1:
		x = (10 ** 9 - 1) // (h * w - 1)
		for i in range(H):
			for j in range(W):
				L[i][j] = x
	for i in range(H // h):
		for j in range(W // w):
			L[(i + 1) * h - 1][(j + 1) * w - 1] = - 10 ** 9
	s = 0
	for i in range(H):
		for j in range(W):
			s += L[i][j]
	if s < 0:
		print("No")
		return
	
	print("Yes")
	for i in range(H):
		print(" ".join(list(map(str, L[i]))))

if __name__ == '__main__':
	main()

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	ll H=in(),W=in();
	vector<vector<int>> M(H,vector<int>(W,0)),V(H,vector<int>(W,1<<30));
	REP(i,H){
		string S=in<string>();
		REP(j,W){
			if(S[j]=='#') M[i][j]=1;
		}
	}
	V[0][0] = M[0][0];
	queue<int> Q;
	Q.push(0);

	while(!Q.empty()){
		auto index = Q.front();
		Q.pop();
		int u=index%W,v=index/W;
		if(u<W-1){
			if((M[v][u+1]==1 && M[v][u]==1) || M[v][u+1]==0){
				if(V[v][u+1]>V[v][u]){
					V[v][u+1]=V[v][u];
					Q.push(u+1+v*W);
				}
			}
			else{
				if(V[v][u+1]>V[v][u]+1){
					V[v][u+1]=V[v][u]+1;
					Q.push(u+1+v*W);
				}
			}
		}
		if(v<H-1){
			if((M[v+1][u]==1 && M[v][u]==1) || M[v+1][u]==0){
				if(V[v+1][u]>V[v][u]){
					V[v+1][u]=V[v][u];
					Q.push(u+(v+1)*W);
				}
			}
			else{
				if(V[v+1][u]>V[v][u]+1){
					V[v+1][u]=V[v][u]+1;
					Q.push(u+(v+1)*W);
				}
			}
		}
	}

	out(V[H-1][W-1]);
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main()
{
	int W, a, b;
	scanf("%d%d%d", &W, &a, &b);
	int i, j;
	int min;
	if (b > a+W) {
		printf("%d\n", b-a-W);
	} else if (a > b+W) {
		printf("%d\n", a-b-W);
	} else {
		printf("0\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using namespace std;
int main()
{
    int N, R;
    cin >> N >> R;
    if (N < 10) {
        cout << R + 100*(10-N) << endl;
    }
    else {
        cout << R << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)

N, M = map(int, input().split())
G = [[] for i in range(N)]
for i in range(N - 1 + M):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    G[a].append(b)


def topological_sort(g):
    topological_list = []
    visited = set()

    def dfs(n):
        for e in g[n]:
            if e not in visited:
                dfs(e)
        topological_list.append(n)
        visited.add(n)

    for i in range(len(g)):
        if i not in visited:
            dfs(i)

    return topological_list[::-1]


topological_order = topological_sort(G)


# 根からの最長経路を計算
dist = [-float('inf')] * N
dist[topological_order[0]] = 0
for n in topological_order:
    for to in G[n]:
        dist[to] = max(dist[to], dist[n] + 1)


ans = [-1] * N
for n in range(N):
    for to in G[n]:
        if dist[n] + 1 == dist[to]:
            ans[to] = n

for p in ans:
    print(p + 1)


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

using namespace std;

int main () {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int x;
  cin >> x;
  if (x >= 100 && x < 600)
    cout << 8;
  else
    if (x < 800)
      cout << 7;
  else
    if (x < 1000)
      cout << 6;
  else
    if (x < 1200)
      cout << 5;
  else
    if (x < 1400)
      cout << 4;
  else
    if (x < 1600)
      cout << 3;
  else
    if (x < 1800)
      cout << 2;
  else
    cout << 1;
  return 0;
}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  map<int64_t,int64_t>a;
  int tmp;
  for(int i=0;i<n;i++){
    cin>>tmp;
    if(a.count(tmp))a.at(tmp)++;
    else a[tmp]=1;
  }
  vector<int64_t>aa;
  for(auto num:a){
    if(num.second<=3&&num.second>=2){
      aa.push_back(num.first);
    }
    else if(num.second>=4){
      aa.push_back(num.first);
      aa.push_back(num.first);
    }
  }
  sort(aa.rbegin(),aa.rend());
  if(aa.size()<2){
    cout <<0<<endl;
    return 0;
  }
  cout <<aa.at(0)*aa.at(1)<<endl;
}

Measured memory_bytes: 9672
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <utility>
typedef long long lint;
//#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
#define INF 1e18
 
int main()
{
	int N, K;
	cin >> N >> K;
	string S;
	cin >> S;
	int m = int('A') - int('a');
 
 
	S[K-1] = char(int(S[K-1]) - m) ; 
 
	cout << S << endl;
 
	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math;
int[] reads() { return readln.split.to!(int[]); }

void main() {
    int n, k; readf("%d %d\n", &n,&k);
    int[] x = reads();
    int x0 = x[0];
    long[] a = x.map!(i => i - x0).array.to!(long[]);

    long ans = long.max;
    foreach (i; 0..n-k+1) {
        long len = a[k - 1 + i] - a[i] + min(x[i].abs, x[k - 1 + i].abs);
        ans = min(ans, len);
    }
    writeln(ans);
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t,n;
    t = 1;
    while(t--) {
     cin >> n;
     cout << 3 * n * n << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
constexpr int INF = 1001001001;
constexpr long long INFL = (1LL<<60);
constexpr double eps = (1e-9);

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

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

  for (int i = k; i < n; i++) {
    if (a[i] > a[i-k]) puts("Yes");
    else puts("No");
  }

  return 0;
}


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

int main(void){
	vector<bool> isprime(123456*2+1);
	for(int i=0;i<isprime.size();i++) isprime[i]=true;
	int upto = (int)sqrt(isprime.size());
	for(int i=2;i<=upto;++i){
		if(isprime[i]){//消されてなければその倍数を消す
			for(int j=2;i*j<isprime.size();++j) isprime[i*j] = false;
		}
	}
	int n,c;
	while(cin>>n,n){
		c=0;
		for(int i=n+1;i<=2*n;++i){
			c+=(isprime[i])?1:0;
		}
		cout<<c<<endl;
	}
	return 0;
}

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

// 挿入ソート
void insertionSort(int* A, int N) {
	for (int i = 1; i < N; i++) {
		int v = A[i]; // 処理する値
		int j = i - 1; // 値より前(左はソート済)

		// 左がv以上なら続ける
		while (j >= 0 && A[j] > v) {
			// 右にもってく
			A[j + 1] = A[j];
			j--;
		}

		// 止まったポジションに持っていく
		A[j + 1] = v;

		// 出力
		for (int i = 0; i < N; i++) {
			cout << A[i];
			if (i != N - 1) cout << " ";
		}
		cout << endl;
	}
}

int N;
int R[100];
int main() {
	cin >> N;

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

	// 入力直後の出力
	for (int i = 0; i < N; i++) {
		cout << R[i];
		if (i != N - 1) cout << " ";
	}
	cout << endl;

	insertionSort(R, N);

	return 0;
}


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

// const long long int MOD = 1000000007;
const int MOD = 1000000007;


int main() {
    int N, ans = 0;
    cin >> N;
    // for (int i = 1; i < N; i++) {
    //     for (int j = 1; j < N; j++) {
    //         if (N > i*j) {
    //             ans++;
    //         }
    //     }
    // }

    for (int i = 1; i < N; i++) {
        int s = N/i;
        if (N%i==0) {
            ans += s-1;
        }
        // else if (s>i) {
        //     ans += s;
        // }
        else {
            ans += s;
        }
        
    }
    cout << ans << endl;
}


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

#define int long long
#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define reps(i, n) for (int (i) = 1; (i) <= (n); (i)++)
#define all(x) (x).begin(), (x).end()
#define bit(n) (1LL << (n))
typedef vector<int> vint;
typedef pair<int, int> pint;
constexpr double pi = 3.1415926535897932384626433832795028;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<typename T, typename U> inline bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> inline bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
struct SetUp {
    SetUp() {
        cout << fixed << setprecision(20);
        cerr << fixed << setprecision(20);
    };
} setUp;

int N, K, Q;
signed main() {
    cin >> N >> K >> Q;
    vint score(N);
    fill(all(score), K - Q);
    vint A(Q);
    rep(i, Q) {
        cin >> A[i];
        score[A[i] - 1]++;
    }
    rep(i, N) {
        if (score[i] <= 0) { cout << "No" << endl; }
        else { cout << "Yes" << endl; }
    }

}

Measured memory_bytes: 2176
s = gets.chomp.split(' ')
W = s[0].to_i#width
H = s[1].to_i#height
N = s[2].to_i#number
my_ary = []
#初期化
H.times do |i|
  my_ary[i] = []
  W.times do |j|
    my_ary[i][j] = 0
  end
end

#黒く塗ったaryを返す
#H,Wがエラーになるかも
def draw_black (ary,x1,y1,a1)
  case a1
  when 1
    #puts '左を黒く'
    H.times do |i|
      x1.times do |j|
        ary[i][j] = 1
      end
    end
    return ary
  when 2
    #puts '右を黒く'
    H.times do |i|
      for j in x1..W-1
        ary[i][j] = 1
      end
    end
    return ary
  when 3
    #puts '下を黒く'
    y1.times do |i|
      W.times do |j|
        ary[i][j] = 1  
      end
    end
    return ary
  when 4
    #puts '上を黒く'
    for i in y1..H-1
      W.times do |j|
        ary[i][j] = 1
      end
    end
    return ary
  end
end

N.times do |i|
  s2 = gets.chomp.split(' ')
  x = s2[0].to_i
  y = s2[1].to_i
  a = s2[2].to_i
  #ary更新
  my_ary = draw_black(my_ary,x,y,a)
  #puts my_ary.to_s
end
#count
cnt = 0
H.times do |i|
  W.times do |j|
    if my_ary[i][j] == 0
      cnt += 1
    end
  end

end

puts cnt

Measured memory_bytes: 1916
import java.io.File;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner in = new Scanner(file);
		
		Scanner in = new Scanner(System.in);

		System.out.println("" + in.next().toUpperCase().charAt(0) + in.next().toUpperCase().charAt(0) + in.next().toUpperCase().charAt(0));
		
	}
}

Measured memory_bytes: 23124
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
    const list = lines[0].split("").map(v=>v-0);
    let sum = list.reduce((a,b)=>a+b, 0);
    let ans = sum;
    let cur = 0;
    list.forEach((v, i)=>{
        ans = Math.max(ans, cur + v-1 + (list.length-i-1) * 9)
        cur += v;
        
    })
    console.log(ans);
});


Measured memory_bytes: 30016
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b;
    cin>>a>>b;
    if (a!=1&&b!=1&&a>b) {
        cout<<"Alice"<<endl;
    } else if (a!=1&&b!=1&&a<b) {
        cout<<"Bob"<<endl;
    } else if (a==b) {
        cout<<"Draw"<<endl;
    } else if (a==1&&b!=1) {
        cout<<"Alice"<<endl;
    } else if (a!=1&&b==1) {
        cout<<"Bob"<<endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sz(x) ((int)(x).size())
#define rep(i,a,b) for (int i=(a); i<(b); i++)
#define per(i,a,b) for (int i=(b-1); i>=(a); i--)
#define debug(x) cout << #x << " => " << x << endl
using namespace std;

#define fi first
#define se second
#define mp make_pair
typedef pair<int,int> pii;

#define pb push_back
typedef vector<int> vi;

typedef long long ll;
typedef long double ld;

const int INF = 7 + 1000000000;
///----------------------------------------------
int qpow(int a,int b) {
	int ret=1;
	for (; b; b>>=1) {
		if (b&1) ret=1ll*ret*a%INF;
		a=1ll*a*a%INF;
	}
	return ret;
}

int main() {

	///read
	int n,m,h,w; cin>>n>>m>>h>>w;

	///work
	pii p1 = mp(n-1-h, w);
	pii p2 = mp(h-1, m-1-w);
	int f1 = 1; {
		rep(i, p1.fi+1, p1.fi+p1.se+1) f1 = 1ll*f1*i%INF;
		rep(i, 2, p1.se+1) f1 = 1ll*f1*qpow(i,INF-2)%INF;
	}
	int f2 = 1; {
		rep(i, p2.fi+1, p2.fi+p2.se+1) f2 = 1ll*f2*i%INF;
		rep(i, 2, p2.se+1) f2 = 1ll*f2*qpow(i,INF-2)%INF;
	}
	int ans = 1ll*f1*f2%INF;
	//debug(p1.fi);
	//debug(p1.se);
	//debug(p2.fi);
	//debug(p2.se);
	//debug(ans);
	for (; p2.se>0; ) {
		f2 = 1ll*f2*p2.se%INF;
		f2 = 1ll*f2*qpow((p2.fi+(p2.se--)),INF-2)%INF;
		//debug(f2);
		f1 = 1ll*f1*(p1.fi+p1.se+1)%INF;
		f1 = 1ll*f1*qpow(++p1.se,INF-2)%INF;
		int f = 1ll*f1*f2%INF;
		//debug(f1);
		ans = (ans + f)%INF;
	}
	printf("%d",ans);
	


}


Measured memory_bytes: 256
h,w = gets.chomp.split(' ').map(&:to_i)
maze = []
h.times do
    maze << gets.chomp.chars
end
def WidthFirstSearch(row,column,meiro)
    if meiro[row][column] == "#"
        return -1
    end
    visited = []
    count_length = 0
    meiro.size.times do |r|
        visited << [-1]*meiro[0].size
    end
    return wfs(row,column,visited,count_length,meiro)
end

def wfs(row,column,visited,length,m)
    q = []
    q<<[row,column,length]
    while q.size > 0
        r,c,l = q.shift
        if visited[r][c]==-1
            visited[r][c]=l
            if ((r+1)<(m.size))&&(m[r+1][c]==".")&&(visited[r+1][c]==-1)
                q<<[r+1,c,l+1]
            end
            if((c+1)<(m[0].size))&&(m[r][c+1]==".")&&(visited[r][c+1]==-1)
                q<<[r,c+1,l+1]
            end
            if((r-1)>=0&&(m[r-1][c]=="."))&&(visited[r-1][c]==-1)
                q<<[r-1,c,l+1]
            end
            if((c-1)>=0&&(m[r][c-1]=="."))&&(visited[r][c-1]==-1)
                q<<[r,c-1,l+1]
            end
        end
    end
    return visited.flatten.max
end

ans = []
h.times do |r|
    w.times do |c|
        ans << WidthFirstSearch(r,c,maze)
    end
end
puts ans.max

Measured memory_bytes: 1916
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <stack> 
#include <map>
#include <queue>
#include <unordered_map>
#include <cassert>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;

#define pb 					push_back

template<typename T,typename S>
ostream& operator <<(ostream& os, pair<T, S> input) {
	os<<"("<<input.first<<", "<<input.second<<")";
	return os;
}

template<typename T>
ostream& operator <<(ostream& os, vector<T> input) {
	for(auto t: input)
		os << t <<" ";

	return os;
}


int N;
string s;
long long MOD = 1e9 + 7;
int dp[3002][3002];

long long solve(int in, int d){
	// cout << in << " : " << d << "\n"; 

	
	if(in == 0)
		return 0;
	
	if(in == 1)
		return d + 1;
	if(d<=0)
		return 0;
	if(dp[in][d] != -1)
		return dp[in][d];
	int l = 1;
	int r= in-1;
	if(s[in-2]=='<') {
		r = d-1;
	} else {
		l = d;
	}
	// cout << in <<","<<d<<": "<<l<<"-"<<r<<"\n";
	long long ans =0 ;
	// for(int i= l; i<=r; i++) {
	// 	ans+=solve(in-1, i);
	// 	ans%=MOD;
	// }
	ans = solve(in -1, r) - solve(in -1, l -1)  + solve(in, d-1);
	ans+=MOD;
	ans%=MOD;
	// cout << in <<" "<<d << ": "<<ans<<"\n";
	return dp[in][d] = ans;

}


void debug() {
	for(int i=0 ;i<=N;i++){
		for(int j = 0; j<=N; j++) {
			cout << solve(i, j)<<" ";
		}
		cout << "\n";
	}
}
int main() {
    //ios_base::sync_with_stdio(false);
	//cin.tie(0);
	//cout.tie(0);

	cin >> N;
	cin >> s;
	memset(dp, -1, sizeof dp);
	long long ans = 0;
	// for(int i = 1; i<=N; i++){
	// 	long long ians=solve(N, i);
	// 	ans+=ians;
	// 	ans%=MOD;
	// }

	// debug();
	 ans = solve(N, N);
	cout << ans <<"\n";



	return 0;
}

Measured memory_bytes: 35712
#include "bits/stdc++.h"
using namespace std;

int main(int argc, char const *argv[])
{
	long long n, m;
	cin >> n >> m;
	if(n == 1 && m == 1) {
		cout << 1 << endl;
	} else if (n == 1) {
		cout << m-2 << endl;
	} else if (m == 1) {
		cout << n-2 << endl;
	} else {
		cout << (n-2)*(m-2) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
using namespace std;

const int N = 2e5 + 9;
int par[N][70];

int main() {
	fastIO;
#ifdef LOCAL
	freopen("input.in", "rt", stdin);
#endif
	int n, a;
	ll k;
	cin >> n >> k;
	for (int i = 1; i <= n; ++i)
		cin >> par[i][0];
	for (int i = 1; i < 64; ++i)
		for (int j = 1; j <= n; ++j)
			par[j][i] = par[par[j][i - 1]][i-1];
	int ans = 1;
	for (int i = 62; i >= 0; --i) {
		if( (1ll << i) <= k) {
			k -= (1ll << i);
			ans = par[ans][i];
		}
	}
	cout << ans;
	return 0;
}


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

int main() {
    int n, nn, n_sum = 0;
    cin >> n;
    nn = n;
    while(nn) {
        n_sum += nn%10;
        nn /= 10;
    }
    
    if(n%n_sum == 0) {
        cout << "Yes" << '\n';
    } else {
        cout << "No" << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
/* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)(s))
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)(s))
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* }}} */

int n, m;
string s[100];
int a[10000], b[10000];

int main(){
  cin >> m >> n;
  rep(i, n) cin >> s[i];
  rep(i, n) rep(j, m){
    if (s[i][j] == 'W') a[j]++;
    else b[j]++;
  }
  tuple<int, int, int> res{inf, inf, inf};
  int e = 0;
  rep(i, m) e += a[i];
  rep(i, m){
    chmin(res, make_tuple(e, i, i + 1));
    e -= a[i];
    e += b[i];
    chmin(res, make_tuple(e, i + 1, i + 2));
  }
  int x, y, z;
  tie(x, y, z) = res;
  cout << y << " " << z << endl;
}

Measured memory_bytes: 4448
#include<bits/stdc++.h>
#include<ctype.h>
# define pb push_back
#define fst first
#define sec second
#define For(i,a,b) for(int i=a;i<b;i++)
#define ll long long int
#define ull unsigned long long int
#define mod 1000000007
#define fo(i,n) for(ll i=0;i<n;i++)
#define endl "\n"
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define fo1(i,n) for(ll i=1;i<=n;i++)
#define boolsize 1000001
#define pi pair<ll,ll>
#define vi vector<ll>
#define vii vector<pi>
using namespace std;
template<typename T>
void showvector(vector <T> v)
{
    for(T x:v)
        cout<<x<<" ";
    cout<<endl;

}
template<typename T>
void showvector1(vector <T> v)
{
    ll n=v.size();
    fo1(i,n-1)
        cout<<v[i]<<endl;

}
template<typename T>
void showset(set <T> s)
{
    for(T x: s)
        cout<<x<<" ";
    cout<<endl;
}
template<class T>
void showvectorpair(vector<T> v)
{
    for(auto it=v.begin();it!=v.end();it++)
        cout<<it->first<<" "<<it->second<<endl;
    cout<<endl;
}
template<typename T,typename P>
void showmap(map <T,P> m)
{
    for(auto it=m.begin();it!=m.end();it++)
        cout<<it->first<<" "<<it->second<<endl;
    cout<<endl;
}
template<typename T>
bool comp(T a,T b)
{
    return (a>b);
}
template<class T>
bool comppair(T a,T b)
{
    if(a.first==b.first)
        return(a.second>b.second);
    return (a.first>b.first);
}
bool sameparity(ll a,ll b)
{
    return (a%2==b%2);
}
bool difparity(ll a,ll b)
{
    return !(a%2==b%2);
}
bool isprime(ll x)
{   if(x<=1)
     return false;
    for(ll i=2;i<=sqrt(x);i++)
    {
        if(x%i==0)
            return false;
    }
    return true;
}
bool iseven(ll x)
{
    return !(x%2);
}
bool isodd(ll x)
{
    return (x%2);
}
/// check for test case before submitting
void vfun()
{
    ll n,k;
    cin>>n;
    vector <ll> v(n);
    fo(i,n)
    cin>>v[i];

}

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0); ///cant use scanf, printf
    cin.tie(0);cout.tie(0); /// no longer auto flush cout before each cin, remove for interactive
    //cout << fixed << setprecision(11); /// no scientific output
    ll test=1;
    //cin>>test;
    while(test--)
    {
            ll n,x;
            cin>>n>>x;
            vector <ll> v(n);
            fo(i,n)
            cin>>v[i];
            ll sum=0;
            fo(i,n-1)
            {
                ll y=v[i]+v[i+1];
                ll diff=y-x;
                if(diff>0)
                {
                    sum+=diff;
                    v[i+1]-=diff;
                    if(v[i+1]<0)
                        v[i+1]=0;

                }
            }
            cout<<sum<<endl;

//         if(vfun())
//            cout<<"YES\n";
//         else
//            cout<<"NO\n";
    }
}
///before sub
/// check for value of zero and single input in array
///loop vars,1LL in mult, equal, one, bounds, int v ll, endl, finish taking inputs
/// check whether test cases are given or not





Measured memory_bytes: 3980
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;

int main(){
	
	int n,q; string s;
	cin>>n>>q>>s;
	vector<int> a(n+1);
	for(int i=2; i<n+1; i++){
		a.at(i)=a.at(i-1);
		if(s.at(i-2)=='A'&&s.at(i-1)=='C'){
			a.at(i)++;
		}
	}
	for(int i=0; i<q; i++){
		int l,r; cin>>l>>r;
		l--; r--;
		if(l==0) cout << a.at(r+1)<<endl;
		else if(s.at(l-1)=='A'&&s.at(l)=='C'){
			cout << a.at(r+1)-a.at(l)-1<<endl;
		}
		else cout << a.at(r+1)-a.at(l)<<endl;
	}
	
}

Measured memory_bytes: 1408
n = int(input())
x = list(map(int,input().split()))
y = []
count = 0

for i in range(n):
  if x[i] % 2 == 0:
    y.append(x[i])
    count += 1

for i in range(count):
  if y[i] % 3 and y[i] % 5:
    print("DENIED")
    exit()
    
print("APPROVED")




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

int main(){
  int n,x[200000];
  int ans1, ans2;
  int sum=0;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> x[i];
    sum+=x[i];
  }
  ans1=sum/n;
  ans2=ans1+1;
  // cout<<"["<<ans1<<"]"<<"["<<ans2<<"]"<<endl;
  int sowa1=0,sowa2=0;
  for(int i=0;i<n;i++){
    sowa1+=(ans1-x[i])*(ans1-x[i]);
    //cout<<"("<<ans1-x[i]<<")";<<"["<<sowa2<<"]";
    sowa2+=(ans2-x[i])*(ans2-x[i]);
    //cout<<"["<<sowa1<<"]"<<"["<<sowa2<<"]";
  }

  cout << min(sowa1,sowa2) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// C - Different Strokes

#define fi first
#define se second

using namespace std;

priority_queue<pair<int,pair<int,int>>> pq;

int main() {
    int N,i,A,B;
    long long ans;
    pair<int,pair<int,int>> cur;

    scanf("%d",&N);

    for (i = 0;i < N;i++) {
        scanf("%d%d",&A,&B);
        pq.push({A + B,{A,B}});
    }

    ans = 0;
    for (i = 0;i < N;i++) {
        if (i % 2 == 0)
            ans += pq.top().se.fi;
        else
            ans -= pq.top().se.se;

        pq.pop();
    }

    printf("%lld\n",ans);

    return 0;
}


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

int main(){
  string str;
  int keep,len;
  while(cin>>str){
    len =str.size();
    int num[len];
    int ans=0;
    for(int i=0;i<len;i++){
      switch (str[i]){
      case 'I': num[i]=1;
	break;
      case 'V': num[i]=5;
	break;
      case 'X': num[i]=10;
	break;
      case 'L': num[i]=50;
	break;
      case 'C': num[i]=100;
	break;
      case 'D': num[i]=500;
	break;
      case 'M': num[i]=1000;
      }
    }
    ans=num[len-1];
    keep=num[len-1];
    for(int i=len-2;i>=0;--i){
      if(num[i] < keep){
	ans-=num[i];
      }
      else{
	ans+=num[i];
      }
      keep=num[i];
    }
    cout<<ans<<endl;
  }
}
    

Measured memory_bytes: 1180
import java.io.*;
import java.util.*;

public class Main {
  private static int solve(int n, int[] ps) {
    int index = 0;
    int count = 0;
    while (index < n) {
      if (ps[index] == index + 1) {
        count++;
        index += 2;
      } else {
        index++;
      }
    }
    return count;
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    int[] ps = reader.nextInt(n);
    out.println(solve(n, ps));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 33136
def cmb(n,r,mod):
    if r<0 or r>n:return 0
    r=min(r,n-r)
    return g1[n]*g2[r]*g2[n-r]%mod


mod=998244353
n,m,k=map(int,input().split())
g1=[1,1]
g2=[1,1]
inverse=[0,1]

for i in range(2,n):
    g1.append((g1[-1]*i)%mod)
    inverse.append((-inverse[mod%i]*(mod//i))%mod)
    g2.append((g2[-1]*inverse[-1]%mod))

ans=m*(m-1)**(n-1)
for i in range(k):
    ans +=m*pow(m-1,n-2-i,mod)*cmb(n-1,i+1,mod)
    ans %=mod

print(ans%mod)

Measured memory_bytes: 112448
import java.io.*;
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.StringTokenizer; 
import java.util.*;


public  class Main 
{

	   
	   static class FastReader 
	    { 
	        BufferedReader br; 
	        StringTokenizer st; 
	       
	  
	        public FastReader() 
	        { 
	            br = new BufferedReader(new
	                     InputStreamReader(System.in)); 
	        } 
	  
	        String next() 
	        { 
	            while (st == null || !st.hasMoreTokens()) 
	            { 
	                try
	                { 
	                    st = new StringTokenizer(br.readLine()); 
	                } 
	                catch (IOException  e) 
	                { 
	                    e.printStackTrace(); 
	                } 
	            } 
	            return st.nextToken();
	            
	        } 
	  
	        int nextInt() 
	        { 
	            return Integer.parseInt(next()); 
	        } 
	  
	        long nextLong() 
	        { 
	            return Long.parseLong(next()); 
	        } 
	  
	        double nextDouble() 
	        { 
	            return Double.parseDouble(next()); 
	        } 
	  
	        String nextLine() 
	        { 
	            String str = ""; 
	            try
	            { 
	                str = br.readLine(); 
	            } 
	            catch (IOException e) 
	            { 
	                e.printStackTrace(); 
	            } 
	            return str; 
	        }

			public Character charAt(int i) {
				// TODO Auto-generated method stub
				return null;
			} 
	    } 

  

	  // Complete the hurdleRace function below.
//    public static void solve() {
//    	FastReader s=new FastReader();

   
    public static void main(String[] args) throws IOException {
    	FastReader s=new FastReader();
        int n = s.nextInt();
        int k = s.nextInt();
        int c=0;
        while(n>0) {
        	c++;
        	n/=k;
        }
       	System.out.println(c);
    }	
}





        
    

      
 

Measured memory_bytes: 32412
s = gets.chomp.split("")
k = gets.to_i
ln = s.length

cnt = 0
first = last = 0
tmp = 0
for i in 1..(ln-1)
  if s[i-1] == s[i]
    tmp += 1
  elsif tmp > 0
    cnt += (tmp+1) / 2
    first = tmp+1 if first == 0
    tmp = 0
  else
    first = 1 if first == 0
  end
end
cnt += (tmp+1) / 2 if tmp > 0
cnt *= k
last = tmp+1

if s[0] == s[ln-1]
  if ((first/2) + (last/2)) != (first+last)/2 || (first*last == 0 && (first+last) % 2 == 1)
    cnt += k-1
  end
end

if first == 0
  puts (ln*k)/2
else
  puts cnt
end

Measured memory_bytes: 1788
import sys
input = sys.stdin.buffer.readline
read=sys.stdin.buffer.read

#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''

import itertools
import numpy as np
n, m, q = map(int, input().split())

alis=np.array(list(itertools.combinations_with_replacement(range(1,m+1),n)))
#print(alis,len(alis))
ans=np.zeros(len(alis))
#print(ans)
m = map(int, read().split())
for a,b,c,d in zip(m,m,m,m):#got 4
    cond = alis[:, b - 1] - alis[:, a - 1] == c  # 各要素の(b,a)-1番目list(np限定)
    #print(cond)
    ans+=d*cond#Trueのみ加算
print(int(ans.max()))


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

long long calcPermutation(long long x, long long y)
{
    long long ans = 1;
    for (long long i = 0; i < y; i++)
    {
        ans *= (x - i);
    }
    return ans;
}

long long calcCombination(long long x, long long y)
{
    if (x < y)
    {
        return 0;
    }
    if ((x - y) < y)
    {
        y = x - y;
    }
    long long ans = calcPermutation(x, y);
    while (y > 0)
    {
        ans /= y;
        y--;
    }
    return ans;
}

long long f(long long x)
{
    return x * x * x;
}

long long g(long long n, long long k, long long mod)
{
    long long count = 0;
    for (int i = 1; i <= n; i++)
    {
        if (i % k == mod)
        {
            count++;
        }
    }
    return count;
}

int main()
{
    long long N, K;
    cin >> N >> K;

    long long ans = f(g(N, K, 0));
    if (K % 2 == 0)
    {
        ans += f(g(N, K, K / 2));
        // if (N - K / 2 > 0)
        // {
        //     ans += f(1 + (N - K / 2) / K);
        // }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> Pi;
typedef long long ll;
#define pii Pi
#define pll PL
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef tuple<int, int, int, int> t4;
typedef pair<ll, ll> PL;
typedef long double ldouble;

int n, a[100010];

void solve(){
	scanf("%d", &n);
	rep(i, n)scanf("%d", a+i);
	int ans = 0;
	for(int i=0;i<n;){
		++ans;
		if(i == n-1 || i == n-2)break;
		int chk = 0;
		while(i < n-1){
			if(a[i] > a[i+1]){
				if(chk & 2)break;
				chk |= 1;
			}
			if(a[i] < a[i+1]){
				if(chk & 1)break;
				chk |= 2;
			}
			++i;
		}
		++i;
	}
	printf("%d\n", ans);
}

int main(){
	int Tc = 1; //scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		//printf("Case #%d: ", tc);
		solve();
	}
	return 0;
}

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

using namespace std;

int main()
{
	int n;
	vector<int> x, y;

	cin >> n;

	x.resize(n);
	y.resize(n);

	for(int i = 0; i < n; ++i)
	{
		cin >> x[i] >> y[i];
	}

	map<pair<int, int>, bool> edges;
	for(int i = 0; i < n; ++i)
	{
		for(int j = i + 1; j < n; ++j)
		{
			edges[make_pair(x[i] - x[j], y[i] - y[j])] = true;
			edges[make_pair(x[j] - x[i], y[j] - y[i])] = true;
		}
	}

	int max_cnt = 0;
	for(auto edge : edges)
	{
		int ex = edge.first.first;
		int ey = edge.first.second;

		//cout << "e " << ex << " " << ey << endl;

		int cnt = 0;
		for(int i = 0; i < n; ++i)
		{
			for(int j = 0; j < n; ++j)
			{
				if(x[i] + ex == x[j] && y[i] + ey == y[j])
				{
					//cout << x[i] << "," << y[i] << " " << x[j] << "," << y[j] << endl;
					++cnt;
				}
			}
		}
		max_cnt = max(max_cnt, cnt);
	}

	//cout << max_cnt << endl;
	cout << n - max_cnt << endl;
}

Measured memory_bytes: 384
import math
n = int(input())
a = []
b = []
for i in range(n):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)
a = sorted(a)
b = sorted(b)
res = 0
if n % 2 == 1:
    m = n // 2
    m1 = a[m]
    m2 = b[m]
    res = m2 - m1 + 1
else:
    ml = n // 2 - 1
    m1 = a[ml] + a[ml + 1]
    m2 = b[ml] + b[ml + 1]
    res = m2 - m1 + 1

print(res)

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

int main()
{
    int n;
    int a[1000];
    int suma = 0;
    int sumb = 0;
    
    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    sort(a,a+n,greater<int>());
    for(int i = 0;i < n;i+=2){
        suma += a[i];
    }
    for(int i = 1;i < n;i+=2){
        sumb += a[i];
    }
    cout << suma-sumb << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
from collections import defaultdict
input = sys.stdin.readline

n, q = map(int, input().split())
c = list(map(int, input().split()))
lr = []
for i in range(q):
    l, r = map(int, input().split())
    lr.append((l, r, i))

# 1-indexed
left_index_dict = {}
d = defaultdict(int)

for i, ci in enumerate(c):
    index = d[ci]
    if index in left_index_dict:
        left_index_dict[index].append(i+1)
    else:
        left_index_dict[index] = [i+1]
    d[ci] = i + 1

lr.sort(key=lambda x:x[0])

index = list(left_index_dict.keys())
index.sort()
i = 0

N = n
bit = [0] * (N+1)

def sum(i):
    s = 0
    while i > 0:
        s += bit[i]
        i -= i & -i
    return s

def add(i, x):
    while i <= N:
        bit[i] += x
        i += i & -i

ans = [0] * q

for l, r, _i in lr:
    while i < len(index) and index[i] < l:
        for j in left_index_dict[index[i]]:
            add(j, 1)
        i += 1
    ans[_i] = sum(r) - sum(l-1)

for ansi in ans:
    print(ansi) 
    



    


Measured memory_bytes: 290884
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#include <iostream>
#include <set>

using namespace std;

int main() {

    int N, K;
    cin >> N >> K;

    vector<long> hs;

    for (int i = 0; i < N; i++) {
        long h;
        cin >> h;
        hs.push_back(h);
    }

    sort(hs.begin(), hs.end());

    long result = 1000000001;

    for (int i = K - 1; i < N; i++) {

        result = min(result, hs[i] - hs[i - (K - 1)]);
    }

    cout << result << "\n";

    return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;



int main(){
    int n;
    ll k;
    cin >> n >> k;
    vector<int>a(n);
    rep(i,n){
        cin >> a[i];
        a[i]--;
    }
    vector<int>di(n,0);
    int f,s,ns,now=0,id = 0;
    while(1){
        now = a[now];
        id++;
        if(di[now]==0){
            di[now]=id;
        }
        else{
            f = di[now];
            s = id;
            ns = now;
            break;
        }
    }
    if(s>k){
        rep(i,n){
            if(di[i]==k){
                cout << i+1 << endl;
                return 0;
            }
        }
    }
    k -= f;
    ll roop = s-f;
    ll num = k % roop;
    rep(i,num){
        ns = a[ns];
    }
    cout << ns+1 << endl;
    return 0;
}

Measured memory_bytes: 4844