akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cctype>
#include <utility>
#include <algorithm>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m?-n:n;}
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	for (int N = in(); N; N--) {
		int x = in(), y = in(), b = in(), p = in();
		auto f = [=](int b, int p, double r) {return (int) ((x * b + y * p) * r);};
		outl(min(f(b, p, 1), f(max(5, b), max(2, p), 0.8)));
	}
}


Measured memory_bytes: 2604
N,A,B,C,D=map(int, input().split())

if N%A==0:
    x=N//A
else:
    x=N//A+1
if N%C==0:
    y=N//C
else:
    y=N//C+1

s=x*B
t=y*D

if s < t:
    print(s)
else:
    print(t)


Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
vector<int> ans;
vector<int> h;
int frog1(int N)
{
  if(N<=0)return 0;

  if(N==1)return abs(h[1]-h[0]);
  
  if(ans[N]==-1)
  {
    ans[N] = min(abs(h[N]-h[N-1])+frog1(N-1),abs(h[N]-h[N-2])+frog1(N-2));
  }
  return ans[N];
}
int main(){
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	#ifdef SANS
		freopen("ongoingin.txt","r",stdin);
        freopen("ongoingout.txt","w",stdout);
	#endif
	ll N;
	cin>>N;
	h.resize(N);
	for(int i=0;i<N;i++){
		cin>>h[i];
	}
	ans.resize(N);
	for(int i=0;i<N;i++){
	    ans[i] = -1;
	}
  
	cout<<frog1(N-1)<<endl;
	return 0;
  
}

Measured memory_bytes: 6352
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,d;
    cin>>n>>d;
    int x=d*2+1;
    int y=n%x;
    if(y==0)
        cout<<n/x<<endl;
    else
        cout<<n/x+1<<endl;
}


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


int main(){
long long N,A,B,M,m,Ans=0;
cin >> N >> A >> B;
M=A+B;
m=N/M;
if(N-m*M<A){
cout << m*A+N-m*M << endl;
}else{
  cout << m*A+A << endl;
}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int s1s2s3;
  cin >> s1s2s3;
  
  int s1 = s1s2s3/100;
  int s2 = (s1s2s3-100*s1)/10;
  int s3 = s1s2s3-100*s1-10*s2;
  int x = s1 + s2 + s3;
  cout << x << endl;
}

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

int main() {
  int Ans=1000000,tmp=0;
  string S,T;
  cin>>S>>T;

  for (int i = 0; i <= S.length()-T.length(); i++){
    tmp=0;
    rep(j,T.length()){if(S.at(i+j)!=T.at(j)){tmp++;}
                     }
    Ans=min(Ans,tmp);
  }

  cout<<Ans<<endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main () {
  vector<int>a(100300, 0);
  a[0] = a[1] = -1;
  for (int i = 2; i < 100300; i ++) {
    if (a[i] == 0) {
      a[i] = 1;
      for (int j = 2; j < 100300 / i; j ++) {
        a[i * j] = -1;
      }
    }
  }
  vector<int>b(100300);
  int N = 0;
  for (int i = 2; i < 100300; i ++) {
    if (a[i] == 1) {
      b[N] = i;
      N ++;
    }
  }
  //for (int i = 0; i < 30; i ++) cout << b[i] << endl;
  int X;
  cin >> X;
  int min = 0;
  int max = N - 1;
  while(min != max) {
    int mid = (min + max) / 2;
    if (b[mid] >= X) max = mid;
    else min = mid + 1;
    //cout << min << ' ' << max << endl;
  }
  cout << b[min] << endl;
}
  



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

typedef long long lli;
typedef pair<lli,lli> pll;
typedef vector<lli> vcL;
typedef vector<pll> vPL;


void solve() {
	lli n, m;
	cin >> n >> m;
	cout << ( n%m > 0 ) << '\n';
}

int main() {
	int t = 1;
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
		solve();
	}
	return 0;
}



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

#define int long long
#define double long double
#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 uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
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) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N, A, B;
int P[110];
signed main() {
    cin >> N >> A >> B;
    int a = 0, b = 0, c = 0;
    rep(i, N) {
        cin >> P[i];
        if (P[i] <= A) { a++; }
        else if (P[i] <= B) { b++; }
        else { c++; }
    }
    cout << min({a, b, c}) << endl;
}


Measured memory_bytes: 256
n=int(input())
s=[]
for i in range(n):
    t=str(input())
    if t[0] in 'MARCH':
        s.append(t[0])
#s.sort()
if s==[]:
    print(0)
else:
    l=[]
    l.append(s.count('M'))
    l.append(s.count('A'))
    l.append(s.count('R'))
    l.append(s.count('C'))
    l.append(s.count('H'))
    ans=0
    #print(l)
    for i in range(5):
        for j in range(i+1,5):
            for k in range(j+1,5):
                ans+=l[i]*l[j]*l[k]
                #print(l[i],l[j],l[k])
    print(ans)


Measured memory_bytes: 3924
#include<iostream>
#include<string>
#include<iomanip>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;
typedef long long ll;
#define MAX 301

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

    vector<int> cnt(4);

    for(int i = 0; i<n; i++)
        {
            int x;
            cin>>x;
            cnt[x]++;
        }
    double dp[MAX][MAX][MAX];

    for(int c = 0;c<=n; ++c)
    {
        for(int b = 0;b+c<=n; ++b )
        {
            for(int a = 0; a+b+c<=n;++a)
            {
                if(a==0&&b==0&&c==0)
                    continue;
                double pw = (double) n /(a+b+c);
                double pa = (double) a /(a+b+c);
                double pb = (double) b /(a+b+c);
                double pc = (double) c /(a+b+c);

                dp[a][b][c] = pw;
                if(a)
                    dp[a][b][c]+=pa*dp[a-1][b][c];
                if(b)
                    dp[a][b][c]+=pb*dp[a+1][b-1][c];
                if(c)
                    dp[a][b][c]+=pc*dp[a][b+1][c-1];
            }
        }
    }
     
    cout<<setprecision(12)<<dp[cnt[1]][cnt[2]][cnt[3]]<<"\n";
}

Measured memory_bytes: 213248
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<ll(n);i++)
queue<vector<ll>> q,qn;
vector<vector<ll>>v;
vector<string>s;
ll h,w;
ll cw;
void search(vector<ll>p){
    ll x,y;
    //cout << 'a';
    rep(i, 5){
        //cout << 'b';
        if (p[0] - 2 + i < 0 || p[0] - 2 + i > h - 1) {
            continue;
        }
        //cout << 'b';
        x = p[0] - 2 + i;
        rep(j, 5){
            if (p[1] - 2 + j < 0 || p[1] - 2 + j > w - 1) {
                continue;
            }
            y = p[1] - 2 + j;
            //cout << 'c';
            if (s[x][y]=='.' && (v[x][y] > p[2] || v[x][y] == -1)) {
                ll mark = v[x][y];
                if (abs(i - 2) + abs(j - 2) == 1) {
                    v[x][y] = p[2];
                    q.push(vector<ll> {x, y, v[x][y]});
                }else {
                    v[x][y] = p[2] + 1;
                    if (mark == -1 ) {
                        qn.push(vector<ll> {x, y, v[x][y]});
                    }
                }
                //cout << x << ',' << y <<',' << v[x][y] << endl;
            }
        }
        
    }
}
void bfs(){
    while (!(q.empty()&&qn.empty())) {
        if (q.empty()) {
            q.swap(qn);
            cw++;
        }
        vector<ll> p = q.front();
        //cout << p[0] << ',' << p[1] << ',' << p[2] << endl;
        //v[q.front()[0]][q.front()[1]] = q.front()[2];
        q.pop();
        if (p[2] == cw) {
            search(p);
        }
        
    }
    
    
}
int main() {
    ll ans;
    pair<ll, ll>c,d;
    cin >> h >> w;
    ll a,b;
    cin >> a >>b;
    a--;
    b--;
    c = make_pair(a, b);
    cin >> a >>b;
    a--;
    b--;
    d = make_pair(a, b);
    v.resize(h,vector<ll>(w, -1));
    s.resize(h);
    rep(i, h) cin >> s[i];
    q.push(vector<ll> {c.first, c.second, 0});
    cw = 0;
    bfs();
    
    cout << v[d.first][d.second] << endl;
    
    return 0;
}


Measured memory_bytes: 13996
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;

int main(){
	int ans=0;
	int now=0;
	cin>>N;
	REP(i,N){
		int a;
		cin>>a;
		if(now<=a){
			now=a;
			ans++;
		}
	}
	cout<<ans<<endl;
}

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

int main()
{
        ll N;
        cin >> N;
        map<ll, ll> m;
        for (int i = 0; i < N; ++i) {
                ll A; cin >> A;
                m[A]++;
        }

        ll ans = 0;
        for (auto i : m) {

                if (i.second % 2) ans++;

        }
        cout << ans << endl;


}


Measured memory_bytes: 6528
# -*- coding: utf-8 -*-

N = int(input())

if N == 0:
    print('No')
elif N > 81:
    print('No')
else:
    for i in range(1, 10):
        # 余りが0でかつ商が9以下ならOK
        if N % i == 0 and N // i < 10:
            print('Yes')
            break
    else:
        print('No')


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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

// #define DEBUG_IS_VALID

#ifdef DEBUG_IS_VALID
#define DEB 1 
#else
#define DEB 0
#endif
#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

int main(){
  ll N,X;
  cin >> N >> X ;
  function<ll(ll,ll)> solve = [&](ll x,ll y){
    dump(x,y);
    if(x>y) swap(x,y);
    if(x==0) return -y;
    if(x==y) return x;
    return solve(x,y%x)+2*x*(y/x);
  };
  cout << N+solve(X,N-X) << endl;
  return 0;
}


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

typedef pair<int,int> P;
typedef pair<P,P> P2;

int h, w;

string s[N];


bool check(int y1,int x1,int y2,int x2){
  
  queue<P> q;

  bool used[N][N];

  memset(used,0,sizeof(used));

  q.push(P(y1,x1));
  
  while(!q.empty()){

    P t=q.front(); q.pop();

    int y = t.first, x = t.second;

    if(s[y][x]=='#') continue;
    
    if(used[y][x]) continue;
    
    used[y][x] = true;
    
    if(y + 1 < h) q.push(P(y+1,x));
    
    if(x + 1 < w) q.push(P(y,x+1));
    
  }

  return used[y2][x2];
}


vector<P2> rec;

void addrec(){

  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++){

      if(!('a'<=s[i][j]&&s[i][j]<='z')) continue;
      
      for(int k=i;k<h;k++)
	for(int l=j;l<w;l++)

	  if(s[k][l]=='A'+s[i][j]-'a'&&check(i,j,k,l))
	    if(check(0,0,i,j)&&check(k,l,h-1,w-1))
	      rec.push_back(P2(P(i,j),P(k,l)));
      
    }
  
}


int dp[1005][N][N];
bool used[1005][N][N];

void dfs(int num,int y,int x,bool dr){

  if(used[num][y][x]) return;
  
  used[num][y][x]=true;
  
  int y1 = rec[num].first.first, x1 = rec[num].first.second;
  
  int y2 = rec[num].second.first, x2 = rec[num].second.second;
  
  if(!check(y2,x2,y,x)) return;
  
  dp[num][y][x]=0;

  int res1=0, res2=0;
  
  for(int i=0;i<rec.size();i++){

    int sy, sx, gy, gx;

    sy = rec[i].first.first;
    sx = rec[i].first.second;
    gy = rec[i].second.first;
    gx = rec[i].second.second;

    if(num==i) continue;
    
    if(y1<=sy&&x1<=sx&&gy<=y2&&gx<=x2){
      if(!(y1==sy&&x1==sx)&&!(gy==y2&&gx==x2)){
	if(check(y1,x1,sy,sx)&&check(gy,gx,y2,x2)){
	  dfs(i,y2,x2,1);
	  res1=max(res1,dp[i][y2][x2]);
	}
      }
    }

    if(dr&&gy==y&&gx==x) continue;
    
    if(y2<=sy&&x2<=sx&&gy<=y&&gx<=x){
      if(!(y2==sy&&x2==sx)){
	if(check(y2,x2,sy,sx)&&check(gy,gx,y,x)){
	  dfs(i,y,x,0);
	  res2=max(res2,dp[i][y][x]);
	}
      }
    }
    
  }
  
  dp[num][y][x]=res1+res2+1;
  
}


int main(){
  
  
  while(1){
    
    cin>>h>>w;
    if(!h&&!w) break;
    
    for(int i=0;i<h;i++) cin>>s[i];
    
    memset(dp,-1,sizeof(dp));
    memset(used,0,sizeof(used));
    
    addrec();

    for(int i=0;i<rec.size();i++){

      if(!check(0,0,rec[i].first.first,rec[i].first.second)) continue;
      if(!check(rec[i].second.first,rec[i].second.second,h-1,w-1)) continue;
      
      dfs(i,h-1,w-1,0);
    }

    int ans=-1;
    
    for(int i=0;i<rec.size();i++) ans=max(ans,dp[i][h-1][w-1]);
    
    if(ans==-1&&check(0,0,h-1,w-1)) ans=0;
    
    cout<<ans<<endl;
    
    rec.clear();
  }
  
  return 0;
}

Measured memory_bytes: 18040
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <set>
#include <string>

#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
typedef long long ll;

using namespace std;

int main(){
    int N;
    int ans = 0;
    cin >> N;
    rep(i, N){
        int a;
        cin >> a;
        if(a % 2 == 1){
            ans ++;
        }
    }
    if(ans % 2){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }
    return 0;
}


Measured memory_bytes: 384
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
#sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()

def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

ans=inf

n=I()
m=len(set(LI()))
print(m-(m+1)%2)


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

#define in freopen("input.txt", "r" ,stdin)
#define out freopen("fenceplan.out", "w" ,stdout)
#define ll long long
#define pb push_back
#define fr first
#define sc second
const int mod = 1e9+7;
using namespace std;
ll n;
int main (){
    //in;
    //out;
    //ios_base::sync_with_stdio(0);
    cin >> n;
    string s , t;
    cin >> s >> t;
    for (int i = 0; i < s.length(); i++) {
        cout << s[i] << t[i];
    }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
//#include<math>
#include<algorithm>
#include<map>
//#include<pair>
#include<vector>
#include<set>
#include<stack>
#include<queue>
//priority_queue inside queue
#include<deque>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define nl '\n'
typedef long long ll;
typedef unsigned long long ull;
#define f(i,start,end) for(i=start;i<=end;i++)

bool isPrime(int n)
{
    for(int i=2; i*i<=n; i++)
    {
        if(n%i==0) return false;
    }
    return true;
}

int main()
{
    fast;
    //int t=0; cin >> t; while(t--) //testcases
    {
    char c; cin >> c;
    if(c>='a' && c<='z') cout << 'a';
    else cout << 'A';
    }
    return 0;
}
    

Measured memory_bytes: 3636
import java.io.IOException;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		String A = scan.next();
		String B = scan.next();
		String C = scan.next();

		char ALast = A.charAt(A.length() - 1);
		char BFirst = B.charAt(0);
		char BLast = B.charAt(B.length() - 1);
		char CFirst = C.charAt(0);

		if (ALast != BFirst) {
			System.out.println("NO");
			return;
		}

		if (BLast != CFirst) {
			System.out.println("NO");
			return;
		}

		System.out.println("YES");

	}

	//***********************以下共通関数************************************************
	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


Measured memory_bytes: 27028
def inpl(): return map(int, input().split())
from itertools import accumulate
from bisect import bisect, bisect_left
from collections import Counter
from functools import reduce
from itertools import accumulate
from operator import itemgetter, xor

from sys import setrecursionlimit
setrecursionlimit(10**9)
 
import sys
input = sys.stdin.readline
from collections import Counter
import numpy as np
def inpl(): return list(map(int, input().split()))
N, D = inpl()
S = set([i**2 for i in range(1, 400)])
X = np.array([inpl() for _ in range(N)], dtype=np.int64)

ans = 0
for i in range(N):
    for x in np.power(X - X[i], 2).sum(axis=1):
        if x in S:
            ans += 1
print(ans//2)

Measured memory_bytes: 12232
#include <bits/stdc++.h>
#define LL long long
#define FOR(i,c) for(__typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define F first
#define S second
using namespace std;

const LL mod = 1e9 + 7;

template<typename T> T gcd(T a, T b) { return b == 0?a: gcd(b, a % b); }
template<typename T> T LCM(T a, T b) { return a*(b/gcd(a, b)); }
template<typename T> T expo(T base, T e, T mod) { T res = 1;
  while(e > 0) { if(e&1) res = res * base % mod; base = base * base % mod; e >>= 1; }
  return res;
}
template<typename T, typename S> T expo(T b, S e){if(e <= 1)return e == 0?1: b;\
	return (e&1) == 0?expo((b*b), e>>1): (b*expo((b*b), e>>1));}
template<typename T, typename S> T modinv(T a, S mod) { return expo(a, mod-2, mod); }
template<class T, class S> std::ostream& operator<<(std::ostream &os, const std::pair<T, S> &t) {
	os<<"("<<t.first<<", "<<t.second<<")";
	return os;
}
template<class T> std::ostream& operator<<(std::ostream &os, const std::vector<T> &t) {
	os<<"["; FOR(it,t) { if(it != t.begin()) os<<", "; os<<*it; } os<<"]";
	return os;
}

const int MAXN = 1e5 + 100;
int n, par[MAXN];
int depth[MAXN];
int sub[MAXN];
vector<int> adj[MAXN];

void go(int r, int p, int d) {
	par[r] = p;
	depth[r] = d;
	sub[r] = 1;
	for(auto &elem: adj[r]) {
		if(elem != p) {
			go(elem, r, d + 1);
			sub[r] += sub[elem];
		}
	}
}

int main() {
  ios_base::sync_with_stdio(false);
	int a, b;
	cin >> n;
	for(int i = 1; i < n; i++) {
		cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	go(1, -1, 0);
	int dist = depth[n] - depth[1] - 1;
	int node = n;
	for(int i = 0; i < dist/2; i++) {
		node = par[node];
	}
	a = n - sub[node], b = sub[node];
	if(a > b) {
		cout << "Fennec" << endl;
	} else {
		cout << "Snuke" << endl;
	}
  return 0;
}


Measured memory_bytes: 13184
#include<iostream>
using namespace std;
int main(void) {
	int a, b, c, d;
	int e, f, g, h;
	int x, y, z, o;
	x = 0;
	y = 0;
	z = 0;


	o = 0;


	int hiroshi, kenjiro;

	cin >> a >> b >> c >> d;
	cin >> e >> f >> g >> h;
	if (a >= 10 || b >= 20 || c >= 10 || d >= 20) {

		if (a % 10 == 0) {

			x = a / 10;

		}
		if (c % 10 == 0) {
			y = c / 10;
		}
		if (b % 20 == 0) {
			z = b / 20;
		}
		if (d % 20 == 0) {
			o = d / 20;
		}
		hiroshi = a * e + b * f + x * g + z * h;
		kenjiro = c * e + d * f + y * g + o * h;

	}
	else {
		hiroshi = a * e + b * f;
		kenjiro = c * e + d * f;

	}
	if (hiroshi > kenjiro) {
		cout << "hiroshi" << endl;
	}
	if (hiroshi < kenjiro) {
		cout << "kenjiro" << endl;
	}
	if (hiroshi == kenjiro) {
		cout << "even" << endl;
	}
	

	return 0;
}


Measured memory_bytes: 3104
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		// Scanner sc = new Scanner(new File("test_1.txt"));
		// Scanner sc = new Scanner(new File("test_2.txt"));
		// Scanner sc = new Scanner(new File("in4.txt"));
		int N = sc.nextInt();
		int ans = 0;		
		while (sc.hasNextInt()) {
			int n = sc.nextInt();
			boolean is_prime = true;
			for (int i = 2; i * i <= n; i++)
				if (n % i == 0)
					is_prime = false;
			if (is_prime)
				ans++;
		}

		System.out.println(ans);		
	}
}

Measured memory_bytes: 30656
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
/*
P????
PDDDD=5
PDPDD=5
PDDPD=5
PDDPDD
PDPDPD=6
PDDDDD=6
*/
int main(){
  string S; cin>>S;
  ll ssz=S.size();
  for(ll i=0; i<ssz; i++){
    if(S[i]=='P') cout<<'P';
    else cout<<'D';
  }
  cout<<endl;
}

Measured memory_bytes: 3756
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
#define NIL -2000000001
#define MAX 2000000
#define INFTY 2000000001

int main() {
  int n = 0;
  scanf("%d", &n);

  int min = INFTY;
  for (int i = 1; i < n; i++) {
    int sum = 0;
    int dig;
    int num = i;
    while(num){
      dig = num % 10;
      sum = sum + dig;
      num = num / 10;
    }
    num = n-i;
    while(num){
      dig = num % 10;
      sum = sum + dig;
      num = num / 10;
    }
    if (sum < min) min = sum;
  }

  printf("%d\n", min);

  return 0;
}


Measured memory_bytes: 128
pts = [
    399,
    799,
    1199,
    1599,
    1999,
    2399,
    2799,
    3199,
]
n = int(raw_input())

a = [int(_) for _ in raw_input().split()]
m = 0
d = {}
for ai in a:
    for p in pts:
        if ai <= p:
            d[p] = True
            break
    else:
        m += 1

l = len(d)
print max(l, 1), l + m

Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    
    int n,m;
    cin>>n>>m;
    
    int ga[m][2];
    int mi=1000000,mx=-1000000;
    for(int i=0;i<m;i++){
        cin>>ga[i][0]>>ga[i][1];
        mx = max(ga[i][0], mx);
        mi = min(ga[i][1], mi);
    }
    
    
    int ct=0;
    for(int i=mx;i<=mi;i++){
        ct++;
    }
    
    cout<<ct<<endl;
}


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

using namespace std;
int R,C,N;
int m[300005]={0};
struct Point
{
    int x,y,id;
};
Point p[300005];
stack<int>s;
bool com(Point a,Point b)
{
    if(a.x==0)
    {
        if(b.x==0)
            return a.y<b.y;
        else
            return 1;
    }
    else if(a.y==C)
    {
        if(b.y==C)
            return a.x<b.x;
        else if(b.x==0)
            return 0;
        else
            return 1;
    }
    else if(a.x==R)
    {
        if(b.x==R)
            return a.y>b.y;
        else if(b.x==0||b.y==C)
            return 0;
        else
            return 1;
    }
    else
    {
        if(b.y!=0)
            return 0;
        else
            return a.x>b.x;
    }

}
int main()
{
    scanf("%d%d%d",&R,&C,&N);
    int cnt=0;
    for(int i=0;i<N;i++)
    {
        int x1,y1,x2,y2;
        scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
        if((x1==0||x1==R||y1==0||y1==C)&&(x2==0||x2==R||y2==0||y2==C))
        {
            p[cnt].x=x1;
            p[cnt].y=y1;
            p[cnt].id=i;
            cnt++;
            p[cnt].x=x2;
            p[cnt].y=y2;
            p[cnt].id=i;
            cnt++;

        }
    }
    sort(p,p+cnt,com);
    int ans=1;
    for(int i=0;i<cnt;i++)
    {
        if(m[p[i].id]==1)
        {
            if(s.top()==p[i].id)
            {
                s.pop();
                m[p[i].id]=0;
            }
            else
            {
                ans=0;
                break;
            }
        }
        else
        {
            m[p[i].id]=1;
            s.push(p[i].id);
        }
    }
    if(ans)
        printf("YES");
    else
        printf("NO");
}



Measured memory_bytes: 4480
h, w = [int(i) for i in input().split(" ")]
s = ["" for i in range(0, h)]

for i in range(0, h):
    s[i] = input()
    
def s_cor(i, j):
    global h, w
    if i < 0 or j < 0 or i >= h or j >= w:
        return False
    else:
        return s[i][j] == "#"

p = True
for i in range(0, h):
    for j in range(0, w):
        if s_cor(i, j) and (not s_cor(i - 1, j)) and (not s_cor(i, j - 1)) and (not s_cor(i + 1, j)) and (not s_cor(i, j + 1)):
            p = False
            break
    
if p:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e18;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N,K;
    cin >> N >> K;
    vector<string>A(N);
    for(int i = 0; i < N; i++) {
        int a;
        cin >> a;
        string S = "";
        for(int i = 0; i < 45; i++) {
            S += to_string(a%2);
            a/=2;
        }
        reverse(S.begin(),S.end());
        A[i] = S;
    }
    string S = "";
    for(int i = 0; i < 45; i++) {
        S += to_string(K%2);
        K/=2;
    }
    reverse(S.begin(),S.end());
    bool ok = false,ok2 = false;
    int cnt1 = 0;
    int cnt2 = 0;
    for(int i = 0; i < 45; i++) {
        int X = 0,Y = 0;
        for(int j = 0; j < N; j++) {
            if(A[j][i] == '1') {
                X++;
            }
            else {
                Y++;
            }
        }
        if(X >= Y) {
            cnt1 += (int)pow((double)2,(double)44-i)*X;
            cnt2 += (int)pow((double)2,(double)44-i)*X;
            if(S[i] == '1') {
                ok2 = true;
            }
        }
        else {
            if(ok) {
                cnt2 += (int)pow((double)2,(double)44-i)*Y;
                if(S[i] == '1' || ok2) {
                    cnt1 += (int)pow((double)2,(double)44-i)*Y;
                }
                else {
                    cnt1 += (int)pow((double)2,(double)44-i)*X;
                }
            }
            else {
                cnt2 += (int)pow((double)2,(double)44-i)*X;
                if(S[i] == '1' || ok2) {
                    cnt1 += (int)pow((double)2,(double)44-i)*Y;
                }
                else {
                    cnt1 += (int)pow((double)2,(double)44-i)*X;
                }
            }
        }
        if(S[i] == '1') {
            ok = true;
        }
    }
    cout << max(cnt1,cnt2) << endl;
}


Measured memory_bytes: 12844
H,W,D = map(int,(input().split()))

A = [[] for _ in range(H)]
for i in range(H):
    A[i] = list(map(int,(input().split())))

d = {}
for i in range(H):
    for j in range(W):
        d[A[i][j]] = (i,j)

s = [[] for _ in range(D+1)]
for i in range(1,D+1):
    cost = 0
    s[i].append(0)
    for j in range(i,H*W-D+1,D):
        cost += abs(d[j][0] - d[j+D][0]) + abs(d[j][1] - d[j+D][1])
        s[i].append(cost)

Q = int(input())
for i in range(Q):
    L,R = map(int,(input().split()))
    r = L%D
    if r == 0:
        r = D
    ans = s[r][(R-r)//D]-s[r][(L-r)//D]
    print(ans)

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

const int MAXN = 100005;

int n, m, ai, bi, deg[MAXN];
vector <int> g[MAXN];

bool vis[MAXN];
int a, b;

bool dfs(int u, int parent = -1){
	vis[u] = true;
	
	for(int v : g[u]){
		if(v == parent)continue;
		if(v == a){
			return true;
		}
		if(v != b && !vis[v]){
			if(dfs(v, u)){
				return true;
			}
		}
	}
	return false;
}

int main(){
	scanf("%d %d", &n, &m);
	while(m--){
		scanf("%d %d", &ai, &bi);
		ai--, bi--;
		
		g[ai].push_back(bi);
		g[bi].push_back(ai);
		
		deg[ai]++;
		deg[bi]++;
	}
	
	bool found = false, ok = true;
	int cnt = 0;
	
	for(int i = 0; i < n; i++){
		if(deg[i] % 2 != 0){
			ok = false;
		}else if(deg[i] >= 6){
			found = true;
		}else if(deg[i] == 4){
			cnt++;
		}
	}
	
	if(!ok){
		printf("No\n");
	}else if(found){
		printf("Yes\n");
	}else{
		if(cnt <= 1){
			printf("No\n");
		}else if(cnt >= 3){
			printf("Yes\n");
		}else{
			a = -1, b = -1;
			for(int i = 0; i < n; i++){
				if(deg[i] == 4){
					if(a == -1){
						a = i;
					}else{
						b = i;
					}
				}
			}
			
			if(dfs(a)){
				printf("Yes\n");
			}else{
				printf("No\n");
			}
		}
	}
	
    return 0;
}


Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<long long int> H(N);
  for(int i = 0; i < N; i++) {
    cin >> H[i];
  }
  int ans = 0;
  if(N > 1) {
    for(int i = 0; i < N - 1; i++) {
      int count = 0;
      for(int j = 0; j < N - i - 1; j++) {
        if(H[i + j] >= H[i + j + 1]) {
          count++;
        }
        else {
          break;
        }
      }
      if(count > ans) {
        ans = count;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4004
#include <bits/stdc++.h>
#define owo(i,a, b) for(int i=(a);i<(b); ++i)
#define uwu(i,a, b) for(int i=(a)-1; i>=(b); --i)
#define senpai push_back
#define ttgl pair<int, int>
#define ayaya cout<<"ayaya~"<<endl
 
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
gpu_hash_map<int, int> mp;*/
using ll = long long;
using ld = long double;
const ll MOD = 1000000007;
const ll root = 62;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll binpow(ll a,ll b){ll res=1;while(b){if(b&1)res=(res*a)%MOD;a=(a*a)%MOD;b>>=1;}return res;}
ll modInv(ll a){return binpow(a, MOD-2);}
const double PI = acos(-1);
const double eps = -1e6;
const int INF = 0x3f3f3f3f;
const int NINF = 0xc0c0c0c0;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll NINFLL = 0xc0c0c0c0c0c0c0c0;
const int mxN = 5002;
ll dp[mxN][mxN];
int n;
ll a, b;
int arr[mxN];
int pos[mxN];
int main() {
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    cin.tie(0)->sync_with_stdio(0);
    cin>>n>>a>>b;
    owo(i, 0, n) {
        cin>>arr[i];
        pos[arr[i]] = i;
    }
    memset(dp, INFLL, sizeof(dp));
    owo(i, 0, mxN) {
        dp[0][i] = 0;
    }
    owo(i, 1, n+1) {
        int p = pos[arr[i]];
        ll mn = INFLL;
        owo(j, 0, n+1) {
            mn = min(mn, dp[i-1][j]);
            if(j>pos[i]) {
                dp[i][j] = min(dp[i][j], mn+a);
            }else {
                dp[i][j] = min(dp[i][j], mn+b);
            }
            if(j==pos[i]) dp[i][n+1] = min(dp[i][n+1], mn);
            if(j==pos[i-1])mn = min(mn, dp[i-1][n+1]);
        }
        /*mn = INFLL;
        uwu(j, n+1, 0) {
            if(j==pos[i-1])mn = min(mn, dp[i-1][n+1]);
            if(j==pos[i]) dp[i][n+1] = min(dp[i][n+1], mn);
            mn = min(mn, dp[i-1][j]);
            if(j<=pos[i]) {
                dp[i][j] = min(dp[i][j], mn+b);
            }
        }*/
        /*owo(j, 0, n+2) {
            cout<<i<<" "<<dp[i][j]<<"\n";
        }*/
    }
    ll ans = INFLL;
    owo(i, 0, n+2) {
        ans = min(ans, dp[n][i]);
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 199152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int a,b,c,d;

int main(){
	cin>>a>>b>>c>>d;
	cout << a*b - (a/c) * (b/d) * c * d << endl;
}


Measured memory_bytes: 3076
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1000000007; 
const int INF = 1000000000; //1e9
const int NIL = -1;
const long long LINF = 1000000000000000000; // 1e18
const long double EPS = 1E-10;

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



int main(){
    int N, M, cnt(0), A, B; std::cin >> N >> M;
    std::vector<int> H(N);
 //   std::vector<bool> bad(N, false);
    std::vector<std::vector<int>> G(N);
    for(int i(0); i < N; ++i) std::cin >> H[i];
    for(int i(0); i < M; ++i){
        std::cin >> A >> B;
        --A; --B;
        G[A].push_back(B);
        G[B].push_back(A);
    }
    bool ng(false);
    for(int i(0); i < N; ++i){
        ng = false;
        for(int v: G[i]){
            if(H[i] <= H[v]) ng = true;
            if(ng) break;
        }
        if(!ng) ++cnt;
    }
    std::cout << cnt << std::endl;
    return 0;
}


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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

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

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

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

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

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

  int n; cin >> n;
  vll a(n+1);
  REP(i, n) cin >> a[i];
  a[n] = 0;
  n++;
  ll su = 0;
  REP(i, n) {
    su += abs(a[i] - a[(i+1)%n]);
  }

  REP(i, n-1) {
    cout << su - abs(a[i] - a[(i+n-1)%n]) - abs(a[i] - a[(i+1)%n]) + abs(a[(i+n-1)%n] - a[(i+1)%n]) << endl;
  }
}








Measured memory_bytes: 3960
from sys import stdin


def main():
    A, B, K = [int(x) for x in stdin.readline().rstrip().split()]
    x = [x for x in range(1, min(A, B) + 1) if A % x == 0 and B % x == 0]
    print(sorted(x, reverse=True)[K - 1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
# -*- coding:utf-8 -*-
import sys
sys.setrecursionlimit(10 ** 5)
input = sys.stdin.readline
mod = 1000000007
inf = float("INF")
def I(): return int(input().rstrip())
def IR(n): return [I() for _ in range(n)]
def LI(): return list(map(int, input().rstrip().split()))
def LIR(n): return [LI() for _ in range(n)]
def LI_(): return list(map(lambda x: int(x) - 1, input().rstrip().split()))
def LIR_(n): return [LI_() for _ in range(n)]
def F(): return float(input().rstrip())
def FR(n): return [F() for _ in range(n)]
def LF(): return list(map(float, input().rstrip().split()))
def LFR(n): return [LI() for _ in range(n)]
def S(): return input().rstrip()
def SR(n): return [S() for _ in range(n)]
def LS(): return list(sys.stdin.readline().rstrip().split())
def LSR(n): return [LS() for _ in range(n)]
# ↑template↑
# ↓solution↑
n = I()
d = IR(n)
print(len(set(d)))

Measured memory_bytes: 9232
n=int(input())
abc=[list(map(int,input().split())) for _ in range(n)]
dp=[abc[0]]
for i in range(1,n):
    dp.append([])
    dp[-1].append(max(dp[i-1][1]+abc[i][0],dp[i-1][2]+abc[i][0]))
    dp[-1].append(max(dp[i-1][0]+abc[i][1],dp[i-1][2]+abc[i][1]))
    dp[-1].append(max(dp[i-1][0]+abc[i][2],dp[i-1][1]+abc[i][2]))
print(max(dp[-1]))

Measured memory_bytes: 47364
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<bitset>
#include<set>
#define N (105)
#define P (1000000007)
#define M ()
#define inf (0x7f7f7f7f)
#define rg register int
#define Label puts("NAIVE")
#define spa print(' ')
#define ent print('\n')
#define rand() (((rand())<<(15))^(rand()))
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
typedef long double ld;
typedef long long LL;
typedef unsigned long long ull;
using namespace std;
namespace fastIO1{
	inline char read(){
		static const int IN_LEN=1000000;
		static char buf[IN_LEN],*s,*t;
		return (s==t?t=(s=buf)+fread(buf,1,IN_LEN,stdin),(s==t?-1:*s++):*s++);
	}
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=read();!isdigit(c);c=read()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=read())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
	inline char readc(char &c){
		for(c=read();!isalpha(c)&&!isdigit(c);c=read())
		if(c==-1)return 0;
	}
	const int OUT_LEN = 10000000;
	char obuf[OUT_LEN],*ooh=obuf;
	inline void print(char c) {
		if(ooh==obuf+OUT_LEN)fwrite(obuf,1,OUT_LEN,stdout),ooh=obuf;
		*ooh++=c;
	}
	template<class T>
	inline void print(T x){
		static int buf[30],cnt;
		if(x==0)print('0');
		else{
			if(x<0)print('-'),x=-x;
			for(cnt=0;x;x/=10)buf[++cnt]=x%10+48;
			while(cnt)print((char)buf[cnt--]);
		}
	}
	inline void flush(){fwrite(obuf,1,ooh-obuf,stdout);}
}
namespace fastIO2{
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=getchar();!isdigit(c);c=getchar()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=getchar())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
}
using namespace fastIO1;
int n,a[N],f[N][N][N],ans;
void Add(int &x,int y){x+=y; if(x>P)x-=P;}
int main(){
	read(n);
	for(int i=1;i<=n*2-1;i++)read(a[i]);
	sort(a+1,a+2*n),f[n][1][0]=1;
	for(int i=n-1;i;i--)
	for(int l=0;l<=2*n-1;l++)
	for(int r=0;r<=2*n-1-l;r++)
	if(f[i+1][l][r]){
		for(int dl=1;dl<=l+(a[i]!=a[i+1]);dl++)Add(f[i][l+(a[i]!=a[i+1])-dl+1][r+(a[2*n-i]!=a[2*n-i-1])+(dl>1)],f[i+1][l][r]);
		for(int dr=1;dr<=r+(a[2*n-i]!=a[2*n-i-1]);dr++)Add(f[i][l+(a[i]!=a[i+1])+1][r+(a[2*n-i]!=a[2*n-i-1])-dr],f[i+1][l][r]);
	}
	for(int i=0;i<=2*n-1;i++)
	for(int j=0;i+j<=2*n-1;j++)
	Add(ans,f[1][i][j]);
	cout<<ans;
}

Measured memory_bytes: 7552
var stdin = require('fs').readFileSync('/dev/stdin', 'utf8');
var input = stdin.toString().trim().split('\n');

var input = stdin.toString().trim().split('\n');
var cols = input[0].split(' ');
var a = parseInt(cols[0],10);
var b = parseInt(cols[1],10);


console.log(a * b, (a + b) * 2);

Measured memory_bytes: 15468
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(),obj.end()
#define pb(obj) push_back(obj)
#define REP(i,N) for(int i=0;i<N;i++)
typedef long long ll;
ll const MOD=1e9+7;

ll XORWORLD(ll A,ll B){
    if(A==B)return A;
    if(B-A==1)return A^B;
    if(B%2==0)return B^XORWORLD(A,B-1);
    if(A%2==1)return A^XORWORLD(A+1,B);
    else return((B-A+1)/2%2==0?0:1);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A,B;
    ll sub=0;
    cin>>A>>B;
    cout<<XORWORLD(A,B)<<endl;

}


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


int main()
{
    int n,m,a;
    cin>>n>>m;


    a=1;


    for(int i=1; i*i<=m; i++)
    {
        if(m%i==0)
        {
           if(m/i>=n) a=max(i,a);
           if(i>=n) a=max(m/i,a);
        }

    }
    cout<<a<<endl;

    return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::Read;

#[allow(dead_code)]
fn getline() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok().unwrap();
    ret
}

fn get_word() -> String {
    let stdin = std::io::stdin();
    let mut stdin=stdin.lock();
    let mut u8b: [u8; 1] = [0];
    loop {
        let mut buf: Vec<u8> = Vec::with_capacity(16);
        loop {
            let res = stdin.read(&mut u8b);
            if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        if buf.len() >= 1 {
            let ret = String::from_utf8(buf).unwrap();
            return ret;
        }
    }
}

#[allow(dead_code)]
fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() }

fn solve() {
    let q: usize = get();
    let mut former = BinaryHeap::new();
    let mut latter = BinaryHeap::new();
    let mut formersum = 0;
    let mut lattersum = 0;
    let mut cons = 0;
    for _ in 0..q {
        let ty: i32 = get();
        if ty == 1 {
            // UPD
            let mut a: i64 = get();
            let b: i64 = get();
            if former.len() == 0 {
                former.push(a);
                formersum += a;
            } else if former.len() == latter.len() {
                let mut y: i64 = latter.pop().unwrap();
                y = -y;
                lattersum -= y;
                if a > y {
                    std::mem::swap(&mut a, &mut y);
                }
                former.push(a);
                formersum += a;
                latter.push(-y);
                lattersum += y;
            } else {
                latter.push(-a);
                lattersum += a;
                if let (Some(mut x), Some(mut y)) = (former.pop(), latter.pop()) {
                    y = -y;
                    formersum -= x;
                    lattersum -= y;
                    if x > y {
                        std::mem::swap(&mut x, &mut y);
                    }
                    former.push(x);
                    latter.push(-y);
                    formersum += x;
                    lattersum += y;
                }
            }
            cons += b;
        } else {
            // QUE
            let x = former.peek().unwrap();
            let mut ans = -formersum + lattersum;
            ans += (former.len() as i64 - latter.len() as i64) * x;
            println!("{} {}", x, ans + cons);
        }
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 11132