akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(void){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a+b>c+d){
        cout<<"Left"<<endl;
    }else if(a+b<c+d){
        cout<<"Right"<<endl;
    }else{
        cout<<"Balanced"<<endl;
    }
    return 0;
}


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

using namespace std;

int main() {
    int n;      cin >> n;
    double x;
    string s;
    double ans = 0;

    for (int i = 0; i < n; i++) {
        cin >> x >> s;
        if (s == "JPY")
            ans += x;
        else
            ans += 380000*x;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int a,b,d=0,r=0;
    double f=0.0;
        scanf("%d%d",&a,&b);
    d=a/b;
    r=a%b;
    f=(double)a/b;
    printf("%d %d %f\n",d,r,f);
    return 0;
}

Measured memory_bytes: 2668
#include <bits/stdc++.h> 
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define maxnkp make_pair
#define fi first
#define se second
#define eps 1e-10
using namespace std;
typedef long long ll;
const int mods = 1e9+7;
const int maxn = 2e5+10;
const int N = 1e5+10;
const int E = 2e5+10;  
ll n,k;
ll a[maxn];
ll dp[maxn][3][2];

int main(){
	cin>>n;
	F(i,1,n) cin>>a[i];
	ll ans = -infll ;
	if(n%2==0){
		dp[1][0][0] = a[1];
		dp[1][1][0] = a[2]; 
		F(i,3,n){
			dp[i][0][0] = dp[i-2][0][0]+a[i];
			dp[i][1][0] = max(dp[i-2][0][0],dp[i-2][1][0])+a[i+1];
			i++;
		}
		ans = max(dp[n-1][0][0],dp[n-1][1][0]);
		cout<<ans<<endl;
	}
	else{
		if(n==3){
			F(i,1,n){
				ans = max(ans,a[i]);
			}
			cout<<ans<<endl;
			return 0;
		}
		dp[1][0][0] = a[1];
		dp[1][1][0] = a[2];
		dp[1][2][1] = a[3];
		F(i,3,n-1){
			dp[i][0][0] = dp[i-2][0][0]+a[i];
			dp[i][1][0] = max(dp[i-2][0][0],dp[i-2][1][0])+a[i+1];
			if(i<n-1) dp[i][2][1] = max(dp[i-2][0][0],dp[i-2][1][0])+a[i+2];
			dp[i][0][1] = max(dp[i-2][2][1],dp[i-2][0][1]+a[i]);
			dp[i][1][1] = max(dp[i-2][0][1],dp[i-2][1][1])+a[i+1];
			i++;
		}
		//cout<<dp[n-2][1][1]<<" "<<dp[n-2][2][1]<<" "<<dp[n-2][0][1]<<" "<<endl;
		ans = max(dp[n-2][0][1]+a[n],dp[n-2][2][1]);
		ans = max(dp[n-2][0][0],ans);
		ans = max(dp[n-2][1][0],ans);
		cout<<ans<<endl;
	}	
}

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

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

using namespace std;

int main(){
  int n;
  cin >> n;
  if( n == 0 ) puts("1");
  else if( n == 1 ) puts("2");
  else if( n == 2 ) puts("1");
  else puts("0");
  return 0;
}

Measured memory_bytes: 1120
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <cstring>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

struct edge {int to, cap, rev; };
vector<vector<edge> > G;
bool used[10100];
const int INF = 1e6;

void add_edge(int from, int to, int cap=1) {
	G[from].push_back((edge){to,cap,G[to].size()});
	G[to].push_back((edge){from,0,G[from].size()-1});
}

int dfs(int v, int t, int f) {
	if(v == t) return f;
	used[v] = true;
	for(int i = 0; i < G[v].size(); i++) {
		edge & e = G[v][i];
		if(!used[e.to] && e.cap > 0) {
			int d = dfs(e.to, t, min(f,e.cap));
			if(d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s, int t) {
	int flow = 0;
	while(1) {
		memset(used, 0, sizeof(used));
		int f = dfs(s,t,INF);
		if(f == 0) return flow;
		flow += f;
	}
}

int main() {
	int H, W;
	int s, t;
	pii sc, tc;
	cin >> H >> W;
	s = H+W; t = s+1;
	G.resize(H+W+2);
	vector<string> lake(H);
	rep(i,H) cin >> lake[i];
	rep(i,H) {
		rep(j,W) {
			if(lake[i][j] == 'o') {
				add_edge(i,H+j);
				add_edge(H+j,i);
			}
			else if(lake[i][j] == 'S') {
				add_edge(i,s,INF);
				add_edge(s,i,INF);
				add_edge(H+j,s,INF);
				add_edge(s,H+j,INF);
				sc = pii(i,j);
			}
			else if(lake[i][j] == 'T') {
				add_edge(i,t,INF);
				add_edge(t,i,INF);
				add_edge(H+j,t,INF);
				add_edge(t,H+j,INF);
				tc = pii(i,j);
			}
		}
	}
	if(sc.fi == tc.fi || sc.se == tc.se) cout << -1 << endl;
	else cout << max_flow(s,t) << endl;

	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)//iをaからn
#define per(i,a,n) for (int i=a-1;i>=n;i--)//iをnからa
#define db(x) cout << #x << " = " << x << endl
#define db2(x, y) cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"; //デバッグ用
#define all(x) (x).begin(), (x).end()
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
 
 
//sort(all(a)); ソート
//sort(all(a),greater<int>()); 逆順ソート
 
int main() {
  long long int n;
  cin >>n;
  long long int ans=INF;
  long long int xmax=-INF;
  long long int xmin=INF;
  long long int ymax=-INF;
  long long int ymin=INF;
  long long int lotax,lotay;
  int x,y;
rep(i,0,n){
    cin>>x>>y;
    lotax=x+y;
    lotay=x-y;
    if(lotax>xmax){
        xmax=lotax;
    }
    if(lotax<xmin){
        xmin=lotax;
    }
    if(lotay>ymax){
        ymax=lotay;
    }
    if(lotay<ymin){
        ymin=lotay;
    }
}
if(ymax-ymin<xmax-xmin){
    ans=xmax-xmin;
}else{
    ans=ymax-ymin;
}

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

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int ans = 0;
        for (int i = 1; i <= K; i++) {
            for (int j = 1; j <= K; j++) {
                for (int k = 1; k <= K; k++) {
                    int ij_gcd = gcd(i,j);
                    ans += gcd(ij_gcd,k);
                }
            }
        }
        System.out.println(ans);
    }

    private static int gcd(int a, int b) {
        if (b == 0)
            return a;
        return gcd(b, a % b);
    }
}

Measured memory_bytes: 27260
n, s = int(input()), input()
dp = [[0] * (n + 1) for i in range(n + 1)]
for i in range(n):
    for j in range(i + 1, n):
        if s[i] == s[j]:
            dp[i + 1][j + 1] = min(dp[i][j] + 1, j - i)
from itertools import chain
print(max(i for i in chain.from_iterable(dp)))


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

int main()
{
	int n,i;
	cin>>n;
	
	int a[100+1]={0};
	
	for(i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		a[x]=1;
	}
	
	int s=0;
	
	for(i=1;i<=100;i++)
	{
		if(a[i]==1)
		   s++;
	}
	
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t,n;
    cin>>n;
    int *a = new int[n+1]{0};
    for(int i=1;i<=n;++i)
    {
        cin>>a[i];
    }       
    int *dp = new int[n+1]{0};
    dp[1] = 0;
    dp[2] = abs(a[2]-a[1]);
    for(int i=3;i<=n;++i)
    {
        dp[i] = min(dp[i-2] + abs(a[i]-a[i-2]),dp[i-1] + abs(a[i] - a[i-1]));
    }
    cout<<dp[n]<<endl;

    
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<ll>>;
struct edge{ll to ; ll cost ;} ;
using graph =vector<vector<edge>> ;
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
 
 
 int main(){
  ll x ; cin>> x ;
  if(x>=30) cout<<"Yes"<<endl ;
  else cout<<"No"<<endl ;
   return 0 ;
 }



Measured memory_bytes: 3540
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
using namespace std;
string s;
int main() {
  cin>>s;
  s[5] = ' ';
  s[13] = ' ';
  cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;
const int MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

signed main() {
	string S;
	cin >> S;
	rep(i, S.size())cout << 'x';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;

int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        int n;
        cin >> n;
        int a[n+1],dp[n+1]={0};
        for(int i=0; i<n; i++)cin >> a[i];
        dp[0]=0;
        dp[1]=dp[0]+abs(a[1]-a[0]);
        for(int i=2; i<n; i++){
            dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
        }
        cout << dp[n-1] << '\n';

   
    

}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const int MAX_N = 1 << 20;
int n,dat[2*MAX_N-1];
void init(int n_){
  n=1;
  while(n<n_) n*=2;
  for(int i=0;i<2*n-1;i++) dat[i]=-1;
}
void update(int k,int a){
  k+=n-1;
  dat[k]=a;
  while(k>0){
    k=(k-1)/2;
    dat[k]=max(dat[k*2+1],dat[k*2+2]);
  }
}
int query(int a,int b,int k=0,int l=0,int r=n){
  if(r<=a||b<=l) return -1;
  if(a<=l&&r<=b) return dat[k];
  else{
    int vl=query(a,b,k*2+1,l,(l+r)/2);
    int vr=query(a,b,k*2+2,(l+r)/2,r);
    return max(vl,vr);
  }
}
int main(){
  init(300001);
  int m,T;
  cin >> m >> T;
  for(int i=0; i<m; i++) {
    int x;
    cin >> x;
    update(x,x);
  }
  int d[300001];
  memset(d,0,sizeof(d));
  for(int i=2; i<=300000; i++) {
    for(int j=0;;j++) {
      if(j*i>300000) break;
      d[i]=max(d[i],query(j*i,min((j+1)*i,300001))-j*i);
    }
  }
  while(T--) {
    int x;
    cin >> x;
    cout << d[x] << endl;
  }
  return 0;
}

Measured memory_bytes: 8324
x, y = map(int, input().split())
if (x + y) % 3 != 0:
    print(0)
    exit(0)
row = (x + y) // 3
mod = 10 ** 9 + 7
if x < row or x > row * 2:
    print(0)
    exit(0)
x = x - row

def pow_mod(a, x, mod):
    if x == 0:
        return 1 % mod
    if x == 1:
        return a % mod
    half = pow_mod(a, x // 2, mod)
    half = half * half % mod
    if x % 2 == 1:
        half = half * a % mod
    return half

def rev(i, mod):
    return pow_mod(i, mod - 2, mod)

def calc(n, m, mod):
    if n == m or m == 0:
        return 1
    if n - m < m:
        m = n - m
    ans = 1
    for i in range(1, m + 1):
        f1 = ans * (n-i+1) * rev(i, mod) % mod
        ans = f1
    return ans


print(calc(row, x, mod))


Measured memory_bytes: 47124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
#define REP(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for(ll (i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for(ll (i) = (m); (i) < (n); (i)++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

template <uint MD> struct ModInt {
    using M = ModInt;
    const static M G;
    uint v;
    ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    bool operator==(const M& r) const { return v == r.v; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
using Mint = ModInt<1000000007>;

const double PI = 3.14159265358979323846;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main()
{	
    string s, t;
    cin >> s >> t;
    if(t.substr(0, s.length()) == s){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


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

int main()
{
vector <int> v;
int n,a,i,c=0,l,as=0;
cin>>n>>a;
for(i=0;i<a;i++)
{
	cin>>l;
	v.push_back(l);
	c+=v[i];
}
if(c<=n)
{
  as=n-c;
  cout<<as;	
}else
{
	cout<<"-1";
}

}


Measured memory_bytes: 3700
/*
AizuOnline A0068
Title Enclose Pins with a Rubber Band
*/
#include <stdio.h>
#include <float.h>
#include <math.h>
#include <limits.h>
#define MAXPOINT 100
#define PI (3.141592653589793)
//Global data section
int n;
double x[MAXPOINT],y[MAXPOINT];
int flag[MAXPOINT];
//
int find_top_left()
{
  int i,ret;
  double xx,yy;

  yy=DBL_MAX;
  for(i=0;i<n;i++)
    {
      if(yy > y[i])
	{
	  yy=y[i];
	  xx=x[i];
	  ret=i;
	}
      if(yy == y[i])
	{
	  if(xx<x[i])
	    {
	      xx=x[i];
	      ret=i;
	    }
	}
    }
  return(ret);
}
double length(double xx1,double yy1,
		  double xx2,double yy2)
{
  return(sqrt((xx1-xx2)*(xx1-xx2)+(yy1-yy2)*(yy1-yy2)));
}
double inner_product(double xx1,double yy1,
		  double xx2,double yy2)
{
  return(xx1*xx2+yy1*yy2);
}
double calc_cos(double xx1,double yy1,
		  double xx2,double yy2,double xx3,double yy3)
{
  double in_p,len1,len2; // inner_product
  in_p=inner_product(xx1-xx2,yy1-yy2,xx3-xx2,yy3-yy2);
  len1=length(xx1,yy1,xx2,yy2);
  len2=length(xx3,yy3,xx2,yy2);
  return(in_p/len1/len2);
}
int find_next_point(mp1,mp2)
{
  double xx1,yy1,xx2,yy2,xx3,yy3,mincos,minp,cosx;
  int i;

  xx1=x[mp1];
  yy1=y[mp1];
  xx2=x[mp2];
  yy2=y[mp2];
  mincos=1;minp=-1;
  for(i=0;i<n;i++)
    {
      if(flag[i])
	continue;
      xx3=x[i];
      yy3=y[i];
      cosx=calc_cos(xx1,yy1,xx2,yy2,xx3, yy3);
#ifdef DEBUG2
      printf("N:%d,COS:%f\n",i,cosx);
#endif
      if(mincos > cosx)
	{
	  mincos=cosx;
	  minp=i;
	}
    }
  return(minp);
}
int find_2nd(int mp1)
{
  double xx1,yy1,xx2,yy2,xx3,yy3,mincos,minp,cosx;
  int i;

  xx2=x[mp1];
  yy2=y[mp1];
  xx1=xx2-1;
  yy1=yy2;
  mincos=1;minp=-1;
  for(i=0;i<n;i++)
    {
      if(flag[i])
	continue;
      xx3=x[i];
      yy3=y[i];
      cosx=calc_cos(xx1,yy1,xx2,yy2,xx3,yy3);
#ifdef DEBUG2 
      printf("N:%d,COS:%f\n",i,cosx);
#endif
      if(mincos > cosx)
	{
	  mincos=cosx;
	  minp=i;
	}
    }
  return(minp);
}
print_point(int np)
{
  printf("P(%d):%lf,%lf\n",np,x[np],y[np]);
}
main()
{
  int i,np,nps,np1,np2,np3,pc;

  while(EOF!=scanf("%d",&n) && n)
    {
      for(i=0;i<n;i++)
	scanf("%lf,%lf",&x[i],&y[i]);
      for(i=0;i<n;i++)
	flag[i]=0;

      pc=2;
      np1=nps=find_top_left();
      //flag[np1]=-1;
#if DEBUG
      print_point(nps);
#endif
      np2=find_2nd(np1);
      flag[np2]=-1;
#if DEBUG
      print_point(np2);
#endif
      while(1)
	{
	  np3=find_next_point(np1,np2);
	  flag[np3]=-1;
	  if(np3==nps)
	    break;
#if DEBUG
      print_point(np3);
#endif
	  flag[np3]=-1;
	  np1=np2;
	  np2=np3;
	  pc++;
	}
      printf("%d\n",n-pc);
    }
  
return(0);
}

Measured memory_bytes: 636
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

int main()
{
	double x[101], y[101];
	int n;
	scanf("%d", &n);
	int i;
	for (i = 0; i < n; i++)
	{
		scanf("%lf", &x[i]);
	}
	for (i = 0; i < n; i++)
	{
		scanf("%lf", &y[i]);
	}
	double D, total=0;
	int p;
	p = 1;
	for (i = 0; i < n; i++)
	{
		total += powl(abs(x[i] - y[i]), p);
	}
	D = total;
	printf("%lf\n", D);
	p = 2, total = 0;
	for (i = 0; i < n; i++)
	{
		total += powl(abs(x[i] - y[i]), p);
	}
	D = sqrtl(1.0*total);
	printf("%lf\n", D);
	p = 3, total = 0;
	for (i = 0; i < n; i++)
	{
		total += powl(abs(x[i] - y[i]), p);
	}
	D = cbrtl(1.0*total);
	printf("%lf\n", D);
	float pp;
	pp = INFINITY, total = 0;
	for (i = 0; i < n; i++)
	{
		if (1.0*abs(x[i] - y[i]) > total)
		{
			total = 1.0*abs(x[i] - y[i]);
		}
	}
	D = total;
	printf("%lf\n", D);
	return 0;
}

Measured memory_bytes: 1124
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int number=3;
    int array1[]=new int[number];
    int array2[]=new int[number];
    while(true){
      for(int i=0;i<number;i++){
        array1[i]=sc.nextInt();
        array2[i]=1;
      }
      int score=array1[0]+array1[1];
      int at=array1[0]*array1[1];
      int check=0,help=0;
      for(int i=0;i<number;i++){
        if(array1[i]==-1) array2[i]=0;
        check+=array2[i];
      }
      if(check==0)break;
      if(array1[2]>=50)help=1;
      if(at<0||score<30)System.out.println("F");
      else if(score>=80)System.out.println("A");
      else if(score>=65)System.out.println("B");
      else if(help==1||50<=score)System.out.println("C");
      else if(score<50)System.out.println("D");
    }
      sc.close();
  }
}


Measured memory_bytes: 26128
/**In the name of Allah, the Most Merciful, the Most Merciful.**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define INF 9223372036854775806
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define PI 2*acos(0.0)
#define EPS 1e-9
ll max(ll a,ll b) {if(a>b) return a; else return b;}
ll min(ll a,ll b) {if(a<b) return a; else return b;}

ll d[10000006];

int main()
{
    for(int i=1;i<=10000000;i++) d[i]=1;

    for(int i=2;i<=10000000;i++){
        for(int j=i;j<=10000000;j+=i){
            d[j]++;
        }
    }

    ll n;
    cin>>n;

    ll sum=0;
    for(int i=1;i<=n;i++){
        sum+=(i*d[i]);
    }
    cout<<sum<<endl;

    return 0;
}




Measured memory_bytes: 81756
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdint.h>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

typedef ll Node; // Node番号

class TopologicalSort {
public:
  explicit TopologicalSort(ll size) : graph(size), indegree(size) {}

  void AddEdge(Node from, Node to) {
    graph[from].push_back(Edge{to});
    indegree[to]++;
  }

  vector<Node> Sort() {
    queue<Node> st; //入次数が0の頂点の集合
    REP(i, graph.size()) {
      if (indegree[i] == 0) {
        st.push(i);
      }
    }
    vector<Node> ans;
    while (st.size()) {
      Node i = st.front();
      st.pop();
      ans.push_back(i);
      for (const auto &j : graph[i]) {
        indegree[j.to]--;
        if (indegree[j.to] == 0)
          st.push(j.to);
      }
    }
    return ans;
  }

private:
  struct Edge {
    Node to;
  };
  vector<vector<Edge>> graph;
  vector<ll> indegree;
};

map<ll, ll> node_to_order;

bool comp(const pair<ll, ll> &l, const pair<ll, ll> &r) {
  if (l.second < r.second) {
    return true;
  } else if (l.second > r.second) {
    return false;
  } else {
    return node_to_order[l.first] > node_to_order[r.first];
  }
}

void solve(long long N, long long M, std::vector<long long> A,
           std::vector<long long> B) {
  TopologicalSort t(N);
  REP(i, A.size()) { t.AddEdge(A[i] - 1, B[i] - 1); }
  auto ans = t.Sort();
  for (int i : ans) {
    node_to_order[ans[i]] = i;
  }
  vector<pair<ll, ll>> C(A.size());
  REP(i, A.size()) {
    C[i].first = A[i] - 1;
    C[i].second = B[i] - 1;
  }
  sort(ALL(C), comp);
  vector<ll> parent(N, 0);
  ll prev = -1;
  REP(i, C.size()) {
    if (prev == C[i].second) {
      C[i].first = -1;
    } else {
      parent[C[i].second] = C[i].first + 1;
    }
    prev = C[i].second;
  }
  REP(i, N) { std::cout << parent[i] << std::endl; }
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  std::vector<long long> A(N - 1 + M);
  std::vector<long long> B(N - 1 + M);
  for (int i = 0; i < N - 1 + M; i++) {
    scanf("%lld", &A[i]);
    scanf("%lld", &B[i]);
  }
  solve(N, M, std::move(A), std::move(B));
  return 0;
}


Measured memory_bytes: 18036
#include <stdio.h>
#include <string.h>
 
int main(void) {
   char str[100001];
   fgets(str, 100001, stdin);

   int change_cnt = 0;
   int str_length = strlen(str);

   for(int i = 0; i < str_length; i++) {
      if(str[i+1] == '\0') {
      }
      else if(str[i] == str[i+1]) {
         change_cnt++;
         if(str[i] == '0') {
            str[i+1] = '1';
         } else
            str[i+1] = '0';
      }
   }

   printf("%d\n", change_cnt);
   return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# sys.stdin.readline()
import numpy as np
import math
import sys
from collections import defaultdict
input = sys.stdin.readline
n = int(input())
d = defaultdict(int)

for i in range(n):
    k = int(input())
    if d[k] ==1:
        d[k] -=1
    else:
        d[k] +=1
print(sum(d.values()))

Measured memory_bytes: 24060
#include<iostream>

int main(){
    int in_sec = 0;
    int sec = 0, min = 0, hour = 0;
    std::cin >> in_sec;
    hour = (in_sec - in_sec%3600)/3600;
    sec = (in_sec%3600)%60;
    min = (in_sec%3600 - sec)/60;
    std::cout << hour << ":" << min << ":" << sec << std::endl;
    return 0;
}


Measured memory_bytes: 3120
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define NL << endl
using namespace std;
using ll = long long;
int INFINT = 1 << 30;
ll INFLL = 1LL << 60;
int gcd(int a, int b) {return b ? gcd(b, a%b) : a;}

int main() {

	int n;
	cin >> n;

	vector<int> c(n);
	vector<int> s(n);
	vector<int> f(n);

	REP(i, n) {
		cin >> c[i] >> s[i] >> f[i];
	}

	REP(i, n - 1) {
		int t = 0;
		FOR(j, i, n - 1) {
			if (t < s[j]) {
				t = s[j] + c[j];
			} else {
				t += f[j] - ((t - s[j]) - 1) % f[j] - 1 + c[j];
			}
		}
		cout << t NL;
	}

	cout << 0 NL;
	return 0;

}


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

#define int long long
#define max(a,b) max((signed)a,(signed)b)
#define mn(a,b) min((signed)a,(signed)b)

using namespace std;

signed main(){
	int A;
	cin>>A;
    string s="";
    long long temp = A;
    char alphabets[27];
    alphabets[0] = 'z';
    for(int i=1;i<27;i++){
        alphabets[i] = 'a' + i -1;
    }
    // for(auto i:alphabets){
    //     cout<<i<<" ";
    // }
    while(temp>0){
        
        s += alphabets[temp%26];
        if(temp%26==0){
            temp = temp/26;
            temp--;
        }
        else{
            temp = temp/26;
        }
    }
    reverse(s.begin(),s.end());
    cout<<s;
}

Measured memory_bytes: 3624
# include <stdio.h>
# include <string.h>
# include <stdlib.h>
# include <iostream>
# include <vector>
# include <queue>
# include <stack>
# include <map>
# include <math.h>
# include <algorithm>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define MAXN 100005
# define eps 1e-5
# define MAXM 500001
# define MOD 1000000007
# define INF 1000000000
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define FO(i,a,n) for(int i=a; i<n; ++i)
# define bug puts("H");
typedef long long LL;
typedef unsigned long long ULL;
int _MAX(int a, int b){return a>b?a:b;}
int _MIN(int a, int b){return a>b?b:a;}

int main ()
{
    int n;
    scanf("%d",&n);
    LL l=0, r=n, mid;
    while (l<r) {
        mid=(l+r)>>1;
        if (mid*(mid-1)/2+mid>=n) r=mid;
        else l=mid+1;
    }
    printf("%d\n",r);
    n-=r;
    for (int i=r-1; i>=1&&n; --i) {
        if (n<=i) {printf("%d\n",n); break;}
        else {printf("%d\n",i); n-=i;}
    }
    return 0;
}


Measured memory_bytes: 256
def nap(n, cap):
    val = [0] * (cap + 1)
    for _ in range(n):
        w, v = map(int, input().split())
        for wk in range(cap, w - 1, -1):
            nv = val[wk - w] + v
            if val[wk] < nv:
                val[wk] = nv
    return max(val)


n, cap = map(int, input().split())
print(nap(n, cap))


Measured memory_bytes: 9716
#include<stdio.h>
#include<string.h>

int main() {
	int i;
	int n;
	char taro_str[100], hanako_str[100];
	int taro_score = 0, hanako_score = 0;

	scanf("%d", &n);

	for (i = 0;i < n;i++) {
		scanf("%s %s", taro_str, hanako_str);

		if (strcmp(taro_str, hanako_str) < 0) {
			hanako_score += 3;
		}
		else if (strcmp(taro_str, hanako_str) > 0) {
			taro_score += 3;
		}
		else {
			taro_score++;
			hanako_score++;
		}
	}

	printf("%d %d\n", taro_score, hanako_score);

	return 0;
}

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

inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
struct edge{int v,next;}vs[N<<1];
int n,ee,st[N<<1],du[N],Rt,F[N];
inline void addedge(int u,int v)
{
	vs[++ee].v=v;vs[ee].next=st[u];st[u]=ee;
}
inline void dfs(int rt,int pr,int x)
{
	vector <int> v; v.clear();
	for(int i=st[rt];i;i=vs[i].next)
	{
		if(vs[i].v==pr) continue;
		dfs(vs[i].v,rt,x);
		v.push_back(F[vs[i].v]);
	}
	if(!(v.size()&1)) v.push_back(0);
	sort(v.begin(),v.end());
	// printf("son of node %d len of %d\n",rt,x);
	// for(int i=0;i<v.size();i++) printf("%d ",v[i]); puts("");
	int l=0,r=v.size()-1,rs=n+1;
	while(l<=r)
	{
		int mid=(l+r)>>1,fg=1;
		for(int i=0,j=v.size()-1;i<j;i++,j--)
		{
			if(i==mid) i++; if(j==mid) j--;
			fg&=(v[i]+v[j])<=x;
		}
		if(fg) r=mid-1,rs=v[mid];
		else l=mid+1;
	}
	F[rt]=rs+1;
}
inline bool check(int x)
{
	dfs(Rt,0,x); return F[Rt]<=x+1;
}
int main()
{
	// freopen("read.in","r",stdin);
	n=read(); for(int i=1;i<n;i++)
	{
		int u=read(), v=read();
		addedge(u,v); du[u]++;
		addedge(v,u); du[v]++;
	}
	int cnt=0; for(int i=1;i<=n;i++) 
		cnt+=du[i]&1,Rt=du[i]==1? i:Rt;
	int l=0,r=n,B=0;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(check(mid)) r=mid-1,B=mid;
		else l=mid+1;
	}
	cout << (cnt+1)/2 << " " << B << endl;
	return 0;
}

Measured memory_bytes: 12800
N = int(input())
A = list(map(int, input().split()))
A.reverse()
min_max = [[] for _ in range(N+1)]

def main():
    min_max[0] = [A[0], A[0]]
    for i in range(1, N+1):
        a = A[i]
        pre_min, pre_max = min_max[i-1]
        min_max[i] = [(1+pre_min)//2 +a, pre_max +a]
    min_max.reverse()
    if min_max[0][0] != 1:
        print(-1)
        return
    A.reverse()
    ans = 1
    pre = 1
    for i in range(1, N+1):
        a = A[i-1]
        pre = min(2*(pre -a), min_max[i][1])
        ans += pre
    print(ans)

main()

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

const int M = 1000000007;

int main() {
    int n, k; cin >> n >> k;
    long long a[n]; for (int i = 0; i < n; i++) cin >> a[i];

    if (n == k) {
        long long ans = 1;
        for (int i = 0; i < n; i++) ans = ans * a[i] % M;
        if (ans < 0) ans += M;
        cout << ans << endl;
        return 0;
    }
    if (k == 1) {
        cout << (*max_element(a, a+n) + M) % M << endl;
        return 0;
    }

    int z = 0, pos = 0, neg = 0;
    for (int i = 0; i < n; i++)
        if (a[i] == 0) z++;
        else if (a[i] > 0) pos++;
        else neg++;

    if (z > n - k || (z == n - k && neg % 2 == 1)) { cout << "0\n"; return 0; }

    vector<long long> vp, vn;
    for (int i = 0; i < n; i++)
        if (a[i] < 0) vn.push_back(a[i]);
        else if (a[i] > 0) vp.push_back(a[i]);
    sort(vp.begin(), vp.end(), greater<int>());
    sort(vn.begin(), vn.end());

    if (pos == 0 && k % 2 == 1) {
        if (z > 0) {
            cout << "0\n";
        } else {
            sort(vn.begin(), vn.end(), greater<int>());
            long long ans = 1;
            for (int i = 0; i < k; i++) ans = ans * vn[i] % M;
            cout << (ans + M) % M << endl;
        }
        return 0;
    }

    if (vn.size() % 2 == 1) vn.pop_back();
    int i = 0, j = 0;
    long long ans = 1;
    if (k % 2 == 1 && pos > 0) {
        k--;
        ans = vp[0];
        i = 1;
    }
    if ((vp.size() - i) % 2 == 1) vp.pop_back();
    while (k > 0) {
        if (j == vn.size()) {
            ans = ans * vp[i] % M * vp[i+1] % M;
            i += 2;
        } else if (i == vp.size()) {
            ans = ans * vn[j] % M * vn[j+1] % M;
            j += 2;
        } else if (vp[i] * vp[i+1] > vn[j] * vn[j+1]) {
            ans = ans * vp[i] % M * vp[i+1] % M;
            i += 2;
        } else {
            ans = ans * vn[j] % M * vn[j+1] % M;
            j += 2;
        }
        k -= 2;
    }

    cout << ans << endl;
}


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

using ll = long long;
#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

#define INF 1e9

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  set<int> st;
  st.insert(A), st.insert(B), st.insert(C);
  if(st.size() == 2){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll h,w,k;
  cin>>h>>w>>k;
  string S[h];
  for(int i=0; i<h; i++)
    cin>>S[i];
  ll p=1<<h-1, ans=1e9;
  for(int q=0; q<p; q++){//横の全探索
    vector<ll> R(h,0);
    ll cnt=__builtin_popcount(q), flag=0;
    for(int j=0; j<w; j++){
      ll id=0, jg=0;
      for(int i=0; i<h; i++){
        R[id]+=S[i][j]-'0';
        if(R[id]>k)
          jg=1;
        if(q>>i&1)//ビット演算子アンド、どっちも１なら１
          id++;
      }
      if(jg){//もしホワイトがKをこえてたら
        cnt++;
        R.assign(h,0), id=0;//リセット
        for(int i=0; i<h; i++){
          R[id]+=S[i][j]-'0';
          if(R[id]>k) flag=1;
          if(q>>i&1) id++;
        }
      }
      if(flag) break;
    }
    if(!flag) ans=min(ans,cnt);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
int main()
{
	int n,m;
	cin>>n;
	map<string,int> a,b;
	string t;
	for(int i=0;i<n;i++)
	{
		cin>>t;
		if(a.count(t)==1)a[t]++;
		else a[t]=1;
	}
	cin>>m;
	for(int i=0;i<m;i++)
	{
		cin>>t;
		if(b.count(t)==1)b[t]++;
		else b[t]=1;
	}
	map<string,int>::iterator it,ir;
	/*
	for(it=a.begin();it!=a.end();it++)
		cout<<it->first<<" "<<it->second<<endl;
	for(it=b.begin();it!=b.end();it++)
		cout<<it->first<<" "<<it->second<<endl;
	*/
	int maxs=0,x;
	for(it=a.begin();it!=a.end();it++)
	{
		t=it->first;x=it->second;
		if(b.count(t)==0)maxs=max(maxs,x);
		else{
			int temp=a[t]-b[t];
			maxs=max(maxs,temp);
		}
	}
	cout<<maxs<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch RGBTriplets | diff RGBTriplets.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address RGBTriplets.cpp && ./a.out

/*
 
 4/12/2020
 
 5:10-
 
 */

//const int MAX_N=4000+1;
int N;
string S;

vector<char> C={'R','G','B'};
void solve() {
  map<char,LL> cnt;
  LL res=0;
  REP(i,N) {
    FOR(j,i+1,N) if(S[j]!=S[i]) {
      int k=i-(j-i);
      if(k>=0)cnt[S[k]]--;
      FORR(c,C) if(c!=S[i]&&c!=S[j]) {
        res+=cnt[c];
//        dump(i,j,S[i],S[j],c,cnt[c]);
      }
      if(k>=0)cnt[S[k]]++;
    }
    cnt[S[i]]++;
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N>>S;
  solve();
  
  return 0;
}


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

using namespace std;

int main(){
    char s[5], t[5];
    scanf("%s %s", s, t);
    printf("%d\n", (s[0] == t[0]) + (s[1] == t[1]) + (s[2] == t[2]));
    return 0;
}


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

using namespace std;

void solve()
{
	string str;
	while(cin >> str)
	{
		int num[10][10];
		for(int i = 0; i < 10; ++i)
		{
			for(int j = 0; j < 10; ++j)
			{
				num[i][j] = 0;
			}
		}
		for(int i = 0; i < 10; ++i)
		{
			num[0][i] = str[i] - '0';
		}
		for(int i = 1; i < 10; ++i)
		{
			for(int j = 0; j < 10 - i; ++j)
			{
				num[i][j] = (num[i - 1][j] + num[i - 1][j + 1]) % 10;
			}
		}
		cout << num[9][0] << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

class WarshallFloyd():
    def __init__(self, N):
        self.N = N
        self.d = [[float("inf") for i in range(N)]
                  for i in range(N)]  # d[u][v] : 辺uvのコスト(存在しないときは'inf')

    def add(self, u, v, c, directed=False):
        """
        0-indexedであることに注意
        u = from, v = to, c = cost
        directed = Trueなら、有向グラフである
        """
        if directed is False:
            self.d[u][v] = c
            self.d[v][u] = c
        else:
            self.d[u][v] = c

    def WarshallFloyd_search(self):
        # これを d[i][j]: iからjへの最短距離 にする
        # 本来無向グラフでのみ全域木を考えるが、二重辺なら有向でも行ける
        for k in range(self.N):
            for i in range(self.N):
                for j in range(self.N):
                    self.d[i][j] = min(
                        self.d[i][j], self.d[i][k] + self.d[k][j])
        for i in range(self.N):
            self.d[i][i] = 0
        return self.d

n,m = na()
g = WarshallFloyd(n)
abc = []

for i in range(m):
    a,b,c = na()
    g.add(a-1,b-1,c)
    abc.append([a-1,b-1,c])

dp = g.WarshallFloyd_search()

ans = 0
for a,b,c in abc:
    if dp[a][b] < c:
        ans += 1

print(ans)

Measured memory_bytes: 44908
n = int(input())
a, b = map(int, input().split())
p = list(map(int, input().split()))
c = [0, 0, 0]
for pt in p:
    if pt > b:
        c[2] += 1
    elif pt > a:
        c[1] += 1
    else:
        c[0] += 1
print(min(c))

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>

#define size_t int

using namespace std;

int main(int argc, char const *argv[]) {
  char s[4];
  scanf("%s", s);
  if (s[2] == 0) {
    printf("%s\n", s);
  } else {
    for (size_t i = 2; i >= 0; i--) {
      printf("%c", s[i]);
    }
    printf("\n");
  }

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
#define rg register
using namespace std;
typedef long long LL;
const int MAXN = 200005;
const int MAXM = 1000005;
const int MOD = 998244353;

template <typename T> inline void read(T &AKNOI) {
    T x = 0, flag = 1;
    char ch = getchar();
    while (!isdigit(ch)) {
        if (ch == '-') flag = -1;
        ch = getchar();
    }
    while (isdigit(ch)) {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    AKNOI = flag * x;
}

inline void Inc(int &x, int y) {
	x += y; if (x >= MOD) x -= MOD;
}

inline int Mul(int x, int y) {
	return 1LL * x * y % MOD;
}

int n, m, a[MAXN], cnt[MAXM], sum[MAXM];
int pr[MAXM], pcnt, vis[MAXM], mu[MAXM], inv[MAXM], conv[MAXM];

void sieve() {
	mu[1] = 1;
	for (int i = 2; i <= m; ++i) {
		if (!vis[i]) {
			pr[++pcnt] = i;
			mu[i] = MOD - 1;
		}
		for (int j = 1; j <= pcnt && i * pr[j] <= m; ++j) {
			vis[i * pr[j]] = 1;
			if (i % pr[j]) {
				mu[i * pr[j]] = MOD - mu[i];
			} else {
				break;
			}
		}
	}
	for (int i = 1; i <= m; ++i) {
		for (int j = i; j <= m; j += i) {
			Inc(conv[j], Mul(mu[i], inv[j / i]));
		}
	}
}

void init() {
	read(n);
	for (int i = 1; i <= n; ++i) {
		read(a[i]);
		m = max(m, a[i]);
		++cnt[a[i]];
	}
	for (int i = 1; i <= m; ++i) {
		for (int j = i; j <= m; j += i) {
			Inc(sum[i], Mul(j, cnt[j]));
		}
	}
	inv[0] = inv[1] = 1;
	for (int i = 2; i <= m; ++i) {
		inv[i] = Mul(MOD - MOD / i, inv[MOD % i]);
	}
	sieve();
}

void solve() {
	int ans = 0;
	for (int i = 1; i <= m; ++i) {
		Inc(ans, Mul(conv[i], Mul(sum[i], sum[i])));
	}
	for (int i = 1; i <= n; ++i) {
		Inc(ans, MOD - a[i]);
	}
	printf("%d\n", Mul(ans, inv[2]));
}

int main() {
	init();
	solve();
	return 0;
}


Measured memory_bytes: 26368
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main(){


	char ag[200];
	ag['W']=0;
	ag['S']=1;
	ag['E']=2;
	ag['N']=3;
	ag[0]='W';
	ag[1]='S';
	ag[2]='E';
	ag[3]='N';

	char field[31][31];
	int h,w;
	while(cin>>w>>h&&!(w==0&&h==0)){
		int left=0;
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				cin>>field[i][j];
				if(field[i][j]=='W'||field[i][j]=='S'||field[i][j]=='N'||field[i][j]=='E'){
					left++;
				}
			}
		}
		bool na=true;
		for(int i = 0; i < 180; i++){
			//for(int i = 0; i < h; i++){
			//	for(int j =0 ; j < w; j++){
			//		cout<<field[i][j];
			//	}
			//	cout<<endl;
			//}

			vector<char> moves[31][31];
			for(int j = 0; j < h; j++){
				for(int k = 0; k < w; k++){
					if(field[j][k]=='W'||field[j][k]=='S'||field[j][k]=='N'||field[j][k]=='E'){
						pair<int,int> p;
						if(field[j][k]=='W'){
							p.first=-1;
							p.second=0;
						}
						else if(field[j][k]=='S'){
							p.first=0;
							p.second=-1;
						}
						else if(field[j][k]=='N'){
							p.first=0;
							p.second=1;
						}
						else if(field[j][k]=='E'){
							p.first=1;
							p.second=0;
						}

						bool fin=false;
						for(int l = 0; l < 4; l++){
							if(field[j+p.first][k+p.second]=='.'||field[j+p.first][k+p.second]=='X'){
								fin=true;
								//cout<<field[j][k]<<endl;
								field[j][k]=(char)((ag[(ag[field[j][k]]+l+3)%4]));
								moves[j+p.first][k+p.second].push_back(field[j][k]);
								//cout<<(char)((ag[(ag[field[j][k]]+l+3)%4]))<<endl;
								break;
							}
							// ñ]
							int tmp=p.second;
							p.second=p.first;
							p.first=-tmp;
						}

						// àµÚ®æª©Â©ÁÄ¢½ç
						if(fin){
							
						}
					}
				}
			}
			// Ú®óâÌXgð©ÄADæxÌ¢àÌðÚ®AÜ½ÍS[³¹é
			for(int j = 0; j < h; j++){
				for(int k = 0; k < w; k++){
					if(k==2&&j==1){
					//	cout<<endl;
					}
					bool flags[200];
					fill(flags,flags+200,false);
					for(int l = 0; l < moves[j][k].size(); l++){
						flags[moves[j][k][l]]=true;
					}
					// W,S,E,NÌÔÉDæxª é
					if(flags['W']){
						field[j][k+1]='.';
						if(field[j][k]=='X'){
							left--;
						}
						else
							field[j][k]='W';
					}
					else if(flags['S']){
						field[j-1][k]='.';
						if(field[j][k]=='X'){
							left--;
						}
						else
							field[j][k]='S';
					}
					else if(flags['E']){
						field[j][k-1]='.';
						if(field[j][k]=='X'){
							left--;
						}
						else
							field[j][k]='E';
					}
					else if(flags['N']){
						field[j+1][k]='.';
						if(field[j][k]=='X'){
							left--;
						}
						else
							field[j][k]='N';
					}
				}
			}
			if(left==0){
				na=false;
				cout<<i+1<<endl;
				break;
			}
		}
		if(na)
			cout<<"NA"<<endl;
	}

	return 0;
}

Measured memory_bytes: 920
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

const ll MOD = 1000000007;

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

	vector <ll> A(N);
	for (int ii = 0; ii < N; ++ii){
		cin >> A[ii];
	}

	ll ans = 0;
	vector <ll> digZero(61);
	vector <ll> digOne(61);
	for (int ii = 0; ii < N; ++ii){
		ll keta = 0;
		ll val = 1;
		for (int jj = 0; jj < 61; ++jj){
			ll tmp = A[ii] & 1;
			if (tmp == 0){
				ans = (ans + val * digOne[keta]) % MOD;
				digZero[keta] = (digZero[keta] + 1) % MOD;
			} else {
				ans = (ans + val * digZero[keta]) % MOD;
				digOne[keta] = (digOne[keta] + 1) % MOD;
			}
			val = (val * 2) % MOD;
			keta++;
			A[ii] /= 2;
		}
	}

	cout << ans << "\n";

	return 0;
}


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


int main() {

    /*
     * */
    ll N, A, B;
    cin >> N >> A >> B;

    ll count = 0;
    ll ans = 0;

    ll div = N / (A+B);
    ll amari = N % (A+B);
    ans += div * A;
    ans += min(amari, A);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
  
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * (B / gcd(A, B));
}
  
/*------------------------------------------------------------------*/
int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    vector<ll> a_sum(n + 1);
    a_sum[0] = 0;
    _rep(i, 1, n + 1) a_sum[i] = a_sum[i - 1] + a[i - 1];

    ll ans_min = INFINITY; 
    _rep(i, 1, n){
        ans_min = min(ans_min, abs(a_sum[i] - (a_sum[n] - a_sum[i])));
    }
    cout << ans_min << endl;
}


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

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b; cin>>a>>b;
    if(a+b>=10) print("error");
    else print(a+b);
    return 0;
}

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

using ll = long long;
//print(fixed << setprecision(10));
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define repk(i,n,k) for(ll i = k; i < (n); i++)
#define all(n) n.begin(), n.end()
#define print(n) cout << n << endl
double PI = acos(-1.0);
int INF = 1e9;
ll LINF = 1e18;
ll MOD = 1e9+7;


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int n,k;
    cin >> n >> k;

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

    sort(all(p));
    print(accumulate(p.begin(),p.begin()+k,0));

    return 0;
}

Measured memory_bytes: 3612
#include<stdio.h>

int main(){
    int a ,b;
 /* ????????°a ?????¢?????¬?????????????????¢?????¨?????¢?????\?????????????????´??°????????????????´???????????????????????????????*/
      scanf("%d %d", &a ,&b);
      printf("%d", a*b);
      printf(" ");
      printf("%d\n", 2*(a+b));
    return 0;
}

Measured memory_bytes: 1028
N = int(input())
H = list(map(int, input().split()))
walk = 0
key = 0
temp = 0
while key < N-1:
    while True:
        if key == N-1:
            break
        elif H[key] < H[key+1]:
            key += 1
            break
        else:
            temp += 1
            key += 1
    if temp > walk:
        walk = temp
    temp = 0
print(walk)

Measured memory_bytes: 14224