akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
template<class T=ll>struct Graph{
	int n;
	vector<vector<tuple<ll,T>>>edge;
	Graph(int N=1):n(N){edge.resize(n);}
	void add(ll f,ll t,T c,bool d=false){
		edge[f].emplace_back(t,c);
		if(!d)edge[t].emplace_back(f,c);
	}
	void view(){
		rep(i,n)for(auto&e:edge[i])
			puta(i,"=>",get<0>(e),", cost :",get<1>(e));
	}
};
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vvl dist(n,vl(n,LINF));
	vl col(n);
	string s;
	rep(i,n){
		cin>>s;
		rep(j,i)if(s[j]=='1')dist[i][j]=dist[j][i]=1;
		dist[i][i]=0;
	}
	bool ok=true;
	ll ans=0;
	col[0]=1;
	queue<ll> q;
	q.push(0);
	while(!q.empty()){
		ll t=q.front();q.pop();
		rep(i,n){
			if(i==t||dist[t][i]==LINF)continue;
			if(col[i]==0){
				col[i]=col[t]*-1;
				q.push(i);
			}
			ok&=(col[i]==col[t]*-1);
		}
	}
	if(!ok)ans=-1;
	else{
		rep(k,n)rep(i,n)rep(j,n)chmin(dist[i][j],dist[i][k]+dist[k][j]);
		rep(i,n)rep(j,n)if(dist[i][j]!=LINF)chmax(ans,dist[i][j]);
		ans++;
	}
	puta(ans);
	
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1234567;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 2000005;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[SIZE], finv[SIZE], inv[SIZE];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

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

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

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

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

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}

double len(int a, int b, int c, int d) {
	return (double)sqrt((a - c) * (a - c) + (b - d) * (b - d));
}

int a, b, c, ficou, user;
char cake[305][305];
vector<int>pre, fiout;
vector<vector<int>>ans;
bool ok, ook;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> a >> b >> c;
	for (int i = 0; i < a; ++i) {
		for (int j = 0; j < b; ++j) {
			cin >> cake[i][j];
		}
	}

	for (int i = 0; i < a; ++i) {
		int stcou = 0;
		vector<int> mon = {};
		for (int j = 0; j < b; ++j) {
			if (cake[i][j] == '#') { ++stcou; ok = 1; }
		}
		if (!ok) { ++ficou; }
		if (stcou == 0) { ans.push_back(pre); }
		else {
			bool find = 0;
			++user;
			for (int j = 0; j < b; ++j) {
				if (cake[i][j] == '#' && find) { ++user; }
				else if (cake[i][j] == '#') { find = 1; }
				mon.push_back(user);
			}
			ans.push_back(mon);
			pre = mon;
		}
		if (ok && !ook) { fiout = pre; ook = 1; }
	}
	cerr << ficou << endl;

	for (int i = 0; i < ficou; ++i) {
		for (int j = 0; j < fiout.size(); ++j) {
			cout << fiout[j];
			if (j != fiout.size() - 1) { cout << " "; }
		}
		cout << endl;
	}

	for (int i = 0; i < ans.size(); ++i) {
		for (int j = 0; j < ans[i].size(); ++j) {
			cout << ans[i][j];
			if (j != ans[i].size() - 1) { cout << " "; }
		}
		if (ans[i].size() != 0) { cout << endl; }
	}
}

Measured memory_bytes: 1280
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {

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

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		reader.readLine();
		int n = Integer.parseInt(reader.readLine());
		
		int[] y = new int[n];
		int[] x = new int[n];
		int[] sy = new int[n];
		int[] sx = new int[n];
		for (int i = 0; i < n; i++) {
			StringTokenizer to = new StringTokenizer(reader.readLine());
			sx[i] = x[i] = Integer.parseInt(to.nextToken());
			sy[i] = y[i] = Integer.parseInt(to.nextToken());
		}
		Arrays.sort(x);
		Arrays.sort(y);
		int ax = 0;
		int ay = 0;
		long ans = Long.MAX_VALUE;
		int m = (n - 1) / 2;
		int nm = n/2;
		int[] xx = {x[m],x[nm]};
		int[] yy  ={y[m],y[nm]};
		for (int i :xx) {
			for (int j :yy) {
				long res = 0;
				long max = 0;
				for (int k = 0; k < n; k++) {
					long dis = Math.abs(sx[k] - i) + Math.abs(sy[k] - j);
					res += dis * 2;
					max = Math.max(max, dis);
				}
				res -= max;
				if (res < ans) {
					ans = res;
					ax = i;
					ay = j;
				}
			}
		}
		System.out.println(ans);
		System.out.println(ax + " " + ay);
	}
}

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

using namespace std;

const int maxn = 200010;

int n, a[maxn];
int f[maxn], s[maxn], cnt;

void add(int p, int v){
    if(v == 0) return;
    f[cnt] = p;
    s[cnt++] = v;

    if(cnt >= 2 && f[cnt - 2] == f[cnt - 1]){
        s[cnt - 2] += s[cnt - 1];
        cnt--;
    }
}

bool can(int lim){
    cnt = 0;
    add(1, a[1]);
    for(int i = 2; i <= n; i++){
        if(a[i - 1] < a[i]){
            add(1, a[i] - a[i - 1]);
        }
        else if(a[i - 1] == a[i]){
            int p = f[cnt - 1];
            int v = s[cnt - 1];
            cnt--;
            if(p < lim){
                add(p, v - 1);
                add(p + 1, 1);
            }
            else{
                if(cnt == 0) return false;
                int pp = f[cnt - 1];
                int vv = s[cnt - 1];
                cnt--;
                add(pp, vv - 1);
                add(pp + 1, 1);
                add(1, v);
            }
        }
        else{
            int now = a[i - 1];
            while(true){
                if(cnt == 0) return false;
                if(now - s[cnt - 1] <= a[i]) break;
                now -= s[cnt - 1];
                cnt--;
            }
            int need = now - a[i];
            int p = f[cnt - 1];
            int v = s[cnt - 1];
            cnt--;
            add(p, v - need);

            p = f[cnt - 1];
            v = s[cnt - 1];
            cnt--;
            if(p < lim){
                add(p, v - 1);
                add(p + 1, 1);
            }
            else{
                if(cnt == 0) return false;
                int pp = f[cnt - 1];
                int vv = s[cnt - 1];
                cnt--;
                add(pp, vv - 1);
                add(pp + 1, 1);
                add(1, v);
            }
        }
    }
    return true;
}

int main(){
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) scanf("%d", &a[i]);

    int lo = 1, hi = maxn, ans = maxn;
    while(lo <= hi){
        int mid = (lo + hi) / 2;
        if(can(mid)){
            ans = mid;
            hi = mid - 1;
        }
        else lo = mid + 1;
    }
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define check(x) cout << #x << " : " << (x) << endl
#define all(v) v.begin(),v.end() 
#define allr(v) v.rbegin(),v.rend() 
//#define endl '\n'  
typedef  long long ll; 
typedef  unsigned long long ull; 
typedef vector< ll > edge; 
typedef pair< ll , ll > mypair;
typedef priority_queue <ll> max_heap;
typedef priority_queue <ll, vector<ll>, greater<ll> > min_heap;
const ll mod=1e9+7;
const ll inf=1e15+10;
const ll N=1e6+10;

int main()
{
	boost;
	int a[3];
	for(auto &i:a) cin>>i;
	sort(a,a+3);
	cout<<a[0]+a[1];	
  	return 0;
}  

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

int main() {
        int n;
        scanf("%d", &n);
        vector<pair<int, int>> p(n);
        rep(i, n) {
                int x, l;
                scanf("%d%d", &x, &l);
                p[i].first = x - l;
                p[i].second = x + l;
        }
        sort(p.begin(), p.end(), [&](pair<int, int> a, pair<int, int> b) {
                return a.second < b.second;
        });
        int ans = 0;
        int prev = -1e9 - 10;
        rep(i, n) {
                if (prev <= p[i].first) {
                        prev = p[i].second;
                        ans ++;
                }
        }
        printf("%d\n", ans);
        return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define v vector<ll>
#define vv vector<v>
#define p pair<ll,ll>
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,w;
    cin>>n>>w;
    v weight(n+1,-1),value(n+1,-1);
    for (int i=1; i<=n; i++)
        cin>>weight[i]>>value[i];
    vv dp(n+1,v(w+1,0));
    ll ans=0;
    for (int i=1; i<=n; i++)
    {
        for (int j=1; j<=w; j++)
        {
            dp[i][j]=dp[i-1][j];
            if (j>=weight[i])
                dp[i][j]=max(dp[i][j],dp[i-1][j-weight[i]]+value[i]);
            ans=max(ans,dp[i][j]);
        }
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
#define SMIN 3
#define SMAX 1000000
#define NMIN 1
#define NMAX 100
#define BMIN 1
#define BMAX 10000
#define LIM 10000
#define TCASE 20

bool valid[SMAX+1];

bool check(vector<int> v){
  if ( v[0] != 1 ) return false;
  for ( int i = 1; i < v.size(); i++ ){
    if ( v[i-1]+1 != v[i] ) return false;
  }
  return true;
}

int simulate(vector<int> v, int sum){
  assert( SMIN <= sum && sum <= SMAX );
  //if ( !valid[sum]) return -1;
  int cnt = 0;
  while(1){
    if ( check(v) ) return cnt;
    int r = v.size();
    for ( int i = 0; i < v.size(); i++ ) v[i]--;
    vector<int> nv;
    for ( int i = 0; i < v.size(); i++ ) {
      if ( v[i] ) nv.push_back(v[i]);
    }
    v = nv;
    v.push_back(r);
    cnt++;
    if ( cnt > LIM ) return cnt;
  }
}

main(){
  for ( int i = 0; i <= SMAX; i++ ) valid[i] = false;
  int cur = 3, d = 3;
  while( cur <= SMAX ){
    valid[cur] = true;
    cur += d;
    d++;
  }

  int n;
  int tcase = 0;
  while(1){
    cin >> n;
    if ( n == 0 ) break;
    tcase++;
    assert( NMIN <= n && n <= NMAX);
    vector<int> v;
    int x;
    int sum = 0;
    for ( int i = 0; i < n ;i++) {
      cin >> x;
      assert( BMIN <= x && x <= BMAX);
      v.push_back(x);
      sum += x;
    }
    int ans = simulate(v, sum);
    if ( ans > 10000 ) cout << -1 << endl;
    else cout << ans << endl;
  }
  assert( tcase <= TCASE );
}

Measured memory_bytes: 4140
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int A,B,C,D;
  cin>>A>>B>>C>>D;
  long long int X=C;
  long long int Y=D;
  long long int x=C*D;
    if(X<Y){
    long long int tmp = X;
    X = Y;
    Y = tmp;
  }

 long long int r = X % Y;
  while(r!=0){
    X = Y;
    Y = r;
    r = X % Y;
  }
  
  long long int lcm=x/Y;
  
 long long int ans1=B-(B/C);
  long long int ans2=B-(B/D);
  long long int ans3=B-(B/lcm);
  
  long long int ans4=(A-1)-((A-1)/C);
  long long int ans5=(A-1)-((A-1)/D);
  long long int ans6=(A-1)-((A-1)/lcm);
  
 long long int ans=ans1+ans2-ans3-ans4-ans5+ans6;
  
  cout<<ans<<endl;
}

  


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

int main() {
	int n;
	cin>>n;
	string a="";
	string b="";
	string p="";
	string q="";
	char c;
	for(int i=0;i<n;i++)
	{cin>>c;
	a=a+c;
	p=p+c;
	}
	for(int i=0;i<n;i++)
	{cin>>c;
	b=b+c;}
	sort(p.begin(),p.end());
	q=q+p;
	bool flag1=0,flag2=0;
	int i=0,j=0;
	while(1)
	{if(a.compare(p)==0)
	{break;}
	i++;
	flag1=next_permutation(p.begin(), 
                           p.end());}
                           
                           
    while(1)
	{if(b.compare(q)==0)
	{break;}
	j++;
	flag1=next_permutation(q.begin(), 
                           q.end());}
                           
    cout<<abs(i-j);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define N 100005
using namespace std;

int ans[N], sum[2];
string s;
int main()
{
	int i;
	cin >> s;
	for (i = 0; i < s.size(); i++) {
		if (s[i] == 'R') {
			sum[i % 2]++;
		} else if (s[i - 1] == 'R') {
			ans[i - 1] = sum[(i - 1) % 2];
			ans[i] = sum[i % 2] + 1;
			sum[0] = sum[1] = 0;
		}
	}
	sum[0] = sum[1] = 0;
	for (i = s.size() - 1; i >= 0; i--) {
		if (s[i] == 'L') {
			sum[i % 2]++;
		} else if (s[i + 1] == 'L') {
			ans[i + 1] += sum[(i + 1) % 2] - 1;
			ans[i] += sum[i % 2];
			sum[0] = sum[1] = 0;
		}
	}
	for (i = 0; i < s.size(); i++) printf("%d ", ans[i]);
    return 0;
}

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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

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

  ll n, m, ans;
  cin >> n >> m;

  ll a[n], b[n], c[m], d[m];

  REP(i, n) { cin >> a[i] >> b[i]; }
  REP(i, m) { cin >> c[i] >> d[i]; }

  ll dis;

  REP(i, n) {
    dis = INF;
    REP(j, m) {
      if (dis > abs(a[i] - c[j]) + abs(b[i] - d[j])) {
        dis = abs(a[i] - c[j]) + abs(b[i] - d[j]);
        ans = j + 1;
      }
    }
    cout << ans << "\n";
  }
}

Measured memory_bytes: 256
import scala.io.StdIn._
import scala.math._

object Main extends App with StdInHelper {
  val s = readLine()
  val t = readLine()

  println(if (t.startsWith(s) && s.length() + 1 == t.length()) "Yes" else "No")
}

trait StdInHelper {
  def readInts = readLine.split(" ").map(_.toInt)
  def readLongs = readLine.split(" ").map(_.toLong)
}


Measured memory_bytes: 54580
import sys
from operator import itemgetter

INPUT = lambda: sys.stdin.readline().rstrip()
MAP = lambda: map(int, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))

sys.setrecursionlimit(10 ** 9)


def main():
    N, M = MAP()
    AB = [LIST() for i in range(N)]
    L = sorted(AB, key=itemgetter(0))

    money = 0
    cnt = 0
    for i in range(N):
        for j in range(L[i][1]):
            money += L[i][0]
            cnt += 1
            if cnt == M:
                print(money)
                sys.exit()


if __name__ == '__main__':
    main()

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

using namespace std;

int main()
{
    int n;
    int T = 0, H = 0;
    cin >> n;
    
    for(int i = 0; i < n; i++)
    {
        string Tstr, Hstr;
        cin >> Tstr;
        cin >> Hstr;
        
        if(Tstr > Hstr)
        {
            T += 3;
        }
        else if(Hstr > Tstr)
        {
            H += 3;
        }
        else
        {
            T++;
            H++;
        }
    }
    
    cout << T << " " << H << endl;
   
   return 0;
}


Measured memory_bytes: 3236
from itertools import combinations
from collections import Counter

n = int(input())
c = Counter([input()[:1] for _ in range(n)])

Chr = ['M', 'A', 'R', 'C', 'H']
ans = 0

for X, Y, Z in combinations(Chr, 3):
    ans += c.setdefault(X, 0)*c.setdefault(Y, 0)*c.setdefault(Z, 0)

print(ans)


Measured memory_bytes: 4232
#include<stdio.h>
#include<stdlib.h>
#define N 100
int n,t;
int g[N][N],c[N],d[N],f[N];
void V(int);
void D();

int main(){
  int i,j;
  int u,v,k;

  scanf("%d",&n);
  for(i=0; i<n; i++){
    for(j=0; j<n; j++){
      g[i][j]=0;
    }
  }

  for(i=0; i<n; i++){
    scanf("%d%d",&u,&k);
    for(j=0; j<k; j++){
      scanf("%d",&v);
      g[u-1][v-1]=1;
    }
  }

  D();
  for(i=0; i<n; i++)
    printf("%d %d %d\n",i+1,d[i],f[i]);

  return 0;
}

void V(int u){
  int i;
  c[u]=1;
  d[u]=++t;
  for(i=0; i<n; i++){
    if(g[u][i]==0) continue;
    if(c[i]==0) V(i);
  }
  c[u] = 2;
  f[u]= ++t;
}

void D(){
  int i;
  for(i=0; i<n; i++) c[i]=0;
  t = 0;
  for(i=0; i<n; i++){
    if(c[i] == 0) V(i);
  }
}



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

int main(){
  int N;
  int A[20], B[20], C[20];
  cin >> N;
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  for(int i=0; i<N; i++){
    cin >> B[i];
  }
  for(int i=0; i<N-1; i++){
    cin >> C[i];
  }
  int sat = B[A[0]-1];
  for(int i=1; i<N; i++){
    sat+=B[A[i]-1];
    if(A[i-1]+1==A[i]){
      sat+=C[A[i-1]-1];
    }
  }
  cout << sat << endl;
  return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var w string
	fmt.Scan(&w)
	m := map[rune]int{}
	for _, v := range w {
		m[v]++
	}
	for _, v := range m {
		if v%2 > 0 {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<vector>
#include<queue>
#include<set>
#include<algorithm>
#define INF 0x3f3f3f3f
#define mod 1000000009
#define e  2.718281828459045
#define eps 1.0e18
#define PI acos(-1)
#define lowbit(x) (x&(-x))
#define memset(x,y) memset(x,y,sizeof(x))
#define lson i << 1,l,m
#define rson i << 1 | 1,m + 1,r
#define ll long long
using namespace std;
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("text1.in","r",stdin);
	//freopen("text1.out","w",stdout);
	string s;
	cin>>s;
	if(s=="ABC") cout<<"ARC";
	else cout<<"ABC"; 
	return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<typename T, typename U> inline bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> inline bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
struct Init {
    Init() {
        cout << fixed << setprecision(20);
    };
} init;
 
int N;
int x[110], y[110];
signed main() {
    cin >> N;
    for (int i = 0; i < N; i++) { cin >> x[i] >> y[i]; }
    double pi = acos(-1);
    double ans = 0;
    for (double theta = 0; theta < 2 * pi; theta += 1e-5) {
        double a = cos(theta), b = sin(theta);
        double cur = 0;
        for (int i = 0; i < N; i++) {
            double nai = x[i] * a + y[i] * b;
            if (nai > 0) { cur += nai; }
        }
        chmax(ans, cur);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    //https://atcoder.jp/contests/abc141/tasks/abc152_a
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);


            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            long n = inputLongArray[0];
            long m = inputLongArray[1];

            string result = n == m ? "Yes" : "No";

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 13396
import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline
from collections import deque
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    H, W = map(int, readline().split())
    maze = read().split('\n')

    d = [(1,0), (-1,0), (0,1), (0,-1)]
    dist = [[INF]*W for _ in range(H)]
    if maze[0][0]=='#' or maze[H-1][W-1]=='#':
        print(-1)
        sys.exit()
    else:
        dist[0][0] = 0

    que = deque([[0,0]])
    while que:
        y,x = que.popleft()
        for dy, dx in d:
            ny = y+dy
            nx = x+dx
            if 0<=ny<H and 0<=nx<W and maze[ny][nx]=='.' and dist[y][x]+1<dist[ny][nx]:
                dist[ny][nx] = dist[y][x]+1
                que.append([ny,nx])
    if dist[H-1][W-1] == INF:
        print(-1)
    else:
        count = 0
        for c in maze:
            count += c.count('.')
        print(count - dist[H-1][W-1] -1)




if __name__ == '__main__':
    main()



Measured memory_bytes: 9368
package main

import (
	"fmt"
	"strconv"
)

func main() {
  abc126b()
}

func abc126b() {
	var line string
	fmt.Scanf("%s", &line)
	i, _ := strconv.Atoi(line[0:2])
	j, _ := strconv.Atoi(line[2:4])

	yymm := true
	mmyy := true

	if i < 1 || i > 12 {
		mmyy = false
	}
	if j < 1 || j > 12 {
		yymm = false
	}

	ans := "NA"
	if yymm && mmyy {
		ans = "AMBIGUOUS"
	} else if yymm {
		ans = "YYMM"
	} else if mmyy {
		ans = "MMYY"
	}
	fmt.Print(ans)
}


Measured memory_bytes: 512
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	
	if(a<b&&b<c){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 580
s = [int(i) for i in input()]

n = len(s) - 1


for i in range(1 << n):
  operators = ['-'] * n
  for j in range(n):
    if (1 << j) & i:
      operators[n - 1 - j] = '+'

  formula = ''
  for (num, op) in zip(s, operators + [""]):
    formula += str(num) + op
  if (eval(formula) == 7):
    print('{}=7'.format(formula))
    break


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
void solve(std::string S){
    bool s1 = S[0] == 'R';
    bool s2 = S[1] == 'R';
    bool s3 = S[2] == 'R';
    if( s1 & s2 & s3){
      cout << 3 << endl;
    } else if(s2 & (s1 | s3)){
      cout << 2 << endl;
    } else {
      cout << (int) (s1 | s2 | s3) << endl;
    }
}
 
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>

int main(){
    int a,b;
    
    scanf("%d %d", &a, &b);
    
    if(a < b){
        printf("a < b\n");
    }
    else if(a > b){
        printf("a > b\n");
    }
    else if(a == b){
        printf("a == b\n");
    }
    
    return 0;
}


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

int main(){
	int N,M,sum=0;
	cin>>N>>M;
	int arr[M];
	for(int i=0;i<M;i++){
		cin>>arr[i];
		sum=sum+arr[i];
	}
	if(sum<=N){
		cout<<(N-sum);
	}
	else
		cout<<"-1";
return 0;
}


Measured memory_bytes: 3640
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

h,n = inpl()
a = inpl()
print('Yes' if sum(a)>=h else 'No')

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

using namespace std;

#define ll long long int
#define vi vector<int>
#define prec fixed<<setprecision(10)
#define mod 1000000007
#define set(x) __builtin_popcount(x)
#define ffs(x) __builtin_ffs(x)
#define clz(x) __builtin_clz(x)
#define inf 1000000007
#define linf 1000000000000000007


int main(){
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    cout.tie(NULL);
    int k;
    cin >> k;
    int sum=0;
    for(int i=1;i<=k;i++){
    	for(int j=1;j<=k;j++){
    		for(int w=1;w<=k;w++){
    			sum+=__gcd(i,__gcd(j,w));
    		}
    	}
    }
  cout << sum;

}


Measured memory_bytes: 3604
A,I=0,input
for i in range(int(I())):
 a,k=map(int,I().split())
 g=0
 while 1:
  if a<k:g=0;break
  if a%k==0:g=a//k;break
  c=(a//k+a%k)//(a//k+1)
  a-=c*(a//k+1)
 A^=g
print("Takahashi"if A else "Aoki")

Measured memory_bytes: 9192
/* dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pf          push_front
#define endl    '\n'
#define pii         pair<ll ,ll>
#define vll          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005

int main()
{
  ios
  ll m;
  cin>>m;
  cout<<48-m;
  return 0;
}

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

const int dx[] = {-1,1,0,0}, dy[] = {0,0,-1,1};
const int N = 2010;

int n, m, q;
char a[N][N];
int f[N][N], t[2][N][N];

void dfs(int x, int y) {
	a[x][y] = '0';
	pair <int,int> cur = make_pair(x,y);
	for (int i = 0; i < 4; ++i) {
		int nx = x + dx[i], ny = y + dy[i];
		if (nx < 1 || nx > n || ny < 1 || ny > m || a[nx][ny] == '0') continue;
		pair <int,int> prev = cur, nxt = make_pair(nx, ny);
		if (prev > nxt) swap(prev, nxt);

		if (prev.first == nxt.first - 1) {
			t[0][prev.first][prev.second] = 1;
		}
		else t[1][prev.first][prev.second] = 1;
	}
}

void prep(int id) {
	for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) {
		t[id][i][j] += t[id][i - 1][j] + t[id][i][j - 1] - t[id][i - 1][j - 1];
	}
}

int get(int id, int x, int y, int u, int v) {
	if (id == 0) --u;
	else --v;
	return t[id][u][v] - t[id][x - 1][v] - t[id][u][y - 1] + t[id][x - 1][y - 1];
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m >> q;
	for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) 
		cin >> a[i][j], 
		f[i][j] = a[i][j] - '0' + f[i - 1][j] + f[i][j - 1] - f[i - 1][j - 1];

	for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) if (a[i][j] == '1')
		dfs(i, j); 

	prep(0); prep(1);

	while(q--) {
		int x, y, u, v; cin >> x >> y >> u >> v;
		int ans = f[u][v] - f[x - 1][v] - f[u][y - 1] + f[x - 1][y - 1];
		
		ans -= (get(0, x, y, u, v) + get(1, x, y, u, v));
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 53120
H,W = map(int,input().split())
T = []
for i in range(H):
    a = list(input())
    T.append(a)

result = [[0]*W for _ in range(H)]
for i in range(H):
    c = 0
    start = 0
    for j in range(W):
        if T[i][j] == "#":
            for k in range(start,j):
                result[i][k] += c
            start = j + 1
            c = 0
        elif j == W-1:
            c += 1
            for k in range(start,j+1):
                result[i][k] += c
        else:
            c += 1

for i in range(W):
    c = 0
    start = 0
    for j in range(H):
        if T[j][i] == "#":
            for k in range(start,j):
                result[k][i] += c
            start = j + 1
            c = 0
        elif j == H-1:
            c += 1
            for k in range(start,j+1):
                result[k][i] += c
        else:
            c += 1

ans = 0
for i in range(H):
    for j in range(W):
        if T[i][j] == ".":
            ans = max(ans,result[i][j]-1)
        else:
            ans = max(ans,result[i][j])
print(ans)

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

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

    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a.at(i);
    }

    sort(a.rbegin(),a.rend());

    int Alice = 0;
    int Bob = 0;
    
    for(int i = 0; i < n; i++){
        if(i % 2 == 0){
            Alice += a.at(i);
        }
        else{
            Bob += a.at(i);
        }
    }

    int ans = Alice - Bob;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())

r,s,p = map(int,input().split())

T=list(input())

a=[[] for i in range(k)]

for i in range(n):
    a[i%k].append(T[i])


score=0
for j in range(k):
    b=a[j]
    flg=0
    for l in range(len(b)):
        if l==0:
            if b[l]=='r':
                score+=p
            elif b[l]=='s':
                score+=r
            elif b[l]=='p':
                score+=s
        else:
            if b[l-1]==b[l] and flg==0:
                flg=1
                continue
            elif b[l-1]==b[l] and flg==1:
                if b[l]=='r':
                    score+=p
                elif b[l]=='s':
                    score+=r
                elif b[l]=='p':
                    score+=s
                flg=0
            elif b[l-1]!=b[l]:
                if b[l]=='r':
                    score+=p
                elif b[l]=='s':
                    score+=r
                elif b[l]=='p':
                    score+=s
                flg=0

print(score)




Measured memory_bytes: 14116
#include <bits/stdc++.h>
#include <iostream>
#include <ctime>
using namespace std;
#define _LL long long
#define rep(i, n) for (_LL i = 0; i < (_LL)(n); i++)
#define vecrep(itr, v) for (auto itr = (v).begin(); itr != (v).end(); itr++)

int main()
{
    _LL n; cin >> n;
    cout << n * (n - 1) / 2 << endl;
    return 0;    
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

const int vx[4] = {1,0,-1,0};
const int vy[4] = {0,1,0,-1};
int main(){
  int H,W;
  char field[52][52];
  int step[52][52];
  cin >> H >> W;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> field[i][j];
      step[i][j] = -1;
    }
  }
  
  queue<pii> Q;
  Q.push(pii(0,0));
  step[0][0] = 0;
  
  int count = 0;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(field[i][j] == '#'){
        count++;
      }
    }
  }
  
  while(!Q.empty()){
    pii p = Q.front(); Q.pop();
    for(int i = 0; i < 4; i++){
      int y = p.first + vy[i];
      int x = p.second + vx[i];
      if(y >= 0 && y < H && x >= 0 && x < W){
        if(field[y][x] == '#'){
          continue;
        }
        if(step[y][x] == -1){
          step[y][x] = step[p.first][p.second] + 1;
          Q.push(pii(y,x));
        }
      }
    }
  }
  int s = step[H-1][W-1];
  if(s == -1){
    cout << -1 << endl;
  }
  else{
    int ans = H*W - count - s - 1;
    cout << ans << endl;
  }
}

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

int main() {
	ios_base::sync_with_stdio( false );

	int w, n;
	cin >> w >> n;

	vector<pair<int, int>> hl( n );

	for( int i = 0; i < n; ++i ) {
		int a, b;
		char c;
		cin >> a >> c >> b;

		hl[i] = { a, b };
	}

	vector<int> vl( w+1 );

	for( int i = 1; i <= w; ++i ) {
		int x = i;

		for( int j = 0; j < n; ++j ) {
			if( x == hl[j].first ) {
				x = hl[j].second;
			}
			else if( x == hl[j].second ) {
				x = hl[j].first;
			}
		}

		vl[x] = i;
	}

	for( int i = 1; i <= w; ++i ) {
		cout << vl[i] << '\n';
	}
}



Measured memory_bytes: 3072
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int h = sc.nextInt();
        int w = sc.nextInt();
        char c[][] = new char[h][w];
        for(int i = 0; i < h; i++){
        	String s = sc.next();
            for(int j = 0; j < w; j++){
            	c[i][j] = s.charAt(j);
            }
        }
        int a[] = new int[h];
        int x = 0;
        for(int i = 0; i < h; i++){
        	int count = 0;
            for(int j = 0; j < w; j++){
            	if(c[i][j] == '.'){
                	count++;
                }
            }
            if(count != w){
            	a[x] = i;
                x++;
            }
        }
        int b[] = new int[w];
        int y = 0;
        for(int i = 0; i < w; i++){
        	int count = 0;
            for(int j = 0; j < h; j++){
            	if(c[j][i] == '.'){
                	count++;
                }
            }
            if(count != h){
            	b[y] = i;
                y++;
            }
        }
        for(int i = 0; i < x; i++){
        	for(int j = 0; j < y; j++){
            	System.out.print(c[a[i]][b[j]]);
            }
            System.out.println();
        }
    }
}

Measured memory_bytes: 38760
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stdexcept>
#include<cmath>
#include<memory>
#include<algorithm>
#include<cstring>
#include<ctime>
#include<deque>
#include<sstream>
#include<iomanip>
#include<sstream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<climits>
#include<map>
#include<set>
#include<list>
#include<cassert>
#include<deque>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<27
#define all(n) n.begin(),n.end()
#define insert(a,b,c,d) PP(P(a,b),P(c,d))
#define F first
#define S second
#define pb push_back
#define pf push_front
#define LIM 100000
#define x(i) (i/2)%4
#define y(i) (i/2)/4 
#define np(xx,yy) xx%4*2+yy*8 
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
typedef long long ll;
typedef unsigned long long ull;


int n,MCDF;
int imap[5][6];
map<string,bool> used;
string cards;
int dx[5] = {0,-1,-1,+1,1};
int dy[5] = {-1,-1,0,-1,0};


string itos(){
  stringstream ss;
  rep(i,5)
    rep(j,4)
    ss << imap[i][j],ss << " ";

  return (ss.str()).substr(0,(ss.str()).length()-1);
}

string slide(string s,int a,int b){
  if(a > s.length()-1 || b > s.length()-1 || s[a] != s[b])return "-1";  
  string ret;
 
  rep(i,s.length()){  
    if(s[i] == ' ')continue;
    if(i == a || i == b)continue;
    ret += s.substr(i,1)+ " "; 
  }
  
  return ret.substr(0,ret.length()-1);
}


void rec(string s){
  if(s == "" || MCDF == 0){
    MCDF = 0;
    return;
  }
  bool fin = true;
  for(int i=s.length()-1;i >= 0;i--){
    if(s[i] == ' ')continue;
    rep(j,5){
      int nx = x(i)+dx[j],ny = y(i)+dy[j];
      if(!(0<=nx && nx <4 && 0<= ny && ny <5) )continue;
      string sp = slide(s,np(nx,ny),np(x(i),y(i)));
      if(sp == "-1")continue;
      if(!used[sp] && s[np(nx,ny)] == s[np(x(i),y(i))]){
	fin = false;
	used[sp] = true;
	rec(sp);
      }
    }
  }
  if(fin){
    MCDF = min(MCDF,(int)(s.length())/2+1);
  }
}



int main(){
  cin >> n;
  
  while(n-- > 0){
    
    cards.clear();
    used.clear();
    MCDF = 20;
    rep(i,5)
      rep(j,4)cin >> imap[i][j];
    cards = itos();  
    
    for(int i=cards.length()-1;i >= 0; i--){
      if(cards[i] == ' ')continue;
      rep(j,5){    
	int nx = x(i)+dx[j],ny = y(i)+dy[j];
	if(!(0 <= nx && nx <4 && 0 <= ny && ny <5))continue;
	string sp = slide(cards,np(nx,ny),np(x(i),y(i)));
	if(sp == "-1")continue;
	if(!used[sp] && cards[np(nx,ny)] == cards[np(x(i),y(i))]){	  
	  used[sp] = true;
	  rec(sp);
	}
      }
    }

    cout << MCDF << endl;
  }
return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
const ll mod = 1e9 +7;
ll MAX_n = 2e5+1;
ll modpow(ll a, ll b){
  ll res = 1;
  while(b>0){
    if(b&1){
      res =res * a;
      res =res % mod;
    }
    a =a *a%mod;
    b >>=1;
  }
  return res;
}
ll modinv(ll a){
  return modpow(a, mod-2);
}
vector<ll> iv(MAX_n);
void init(ll n){
  for(ll i=1; i<=n; i++){
    iv.at(i) = modinv(i);
  }
  return;
}
ll modc(ll n, ll k){
  if(k>n-k) k = n-k;
  ll res = 1;
  for(ll i=n; i>=n-k+1;i--){
    res = res * i %mod;
  }
  for(ll i =2; i<=k; i++){
    res =res * modinv(i) %mod;
  }
  return res;
}

int main(){
  ll n,k;
  cin>>n>>k;
  ll ans =0;
  for(ll i =k; i<=n+1; i++){
    ans += ((2*n+3-i)*i/2- i*(i+1)/2 +1)%mod;
    ans%=mod;
  }
  ans %=mod;
  cout<<ans<<endl;
  //    cout << fixed << setprecision(10);
}


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

int main(){
    int N, D;
    cin >> N >> D;
    vector<vector <int> > X(N, vector<int> (D));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < D; j++) {
            cin >> X.at(i).at(j);
        }
    }

    int answer = 0;

    for  (int i = 0; i < N - 1; i++){
        for (int j = i + 1; j < N; j++){
            int SUM = 0;
            for (int k = 0; k < D; k++){
                int d = pow((X.at(i).at(k) - X.at(j).at(k)), 2.0);
                SUM += d;
            }

            int r = ceil(sqrt(SUM));
            if (pow(r, 2.0) == SUM){
                answer ++;
            }
        }
    }

    cout << answer << endl;
}

Measured memory_bytes: 256
while True:
    a,op,b = map(str,input().split())
    if op == "?":
        exit()
    if op == "+":
        print(int(a)+int(b))
    if op == "-":
        print(int(a)-int(b))
    if op == "*":
        print(int(a)*int(b))
    if op == "/":
        print(int(float(a)/float(b)))


Measured memory_bytes: 5608
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int N,K;
vector<int>h;
int memo[100010];
bool vis[100010];
int sol(int pos){
  if(pos>=N-1)return 0;
  if(vis[pos])return memo[pos];
  vis[pos]=1;
  int mi=2e9;
  for(int i=pos+1;i<=min(N-1,pos+K);i++)mi=min(mi,sol(i)+abs(h[pos]-h[i]));
  return memo[pos]=mi;
}
int main(){
		ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
    cin>>N>>K;
    for(int i=0;i<N;i++){
      int a;
      cin>>a;
      h.push_back(a);
    }
    h.push_back(h.back());
    h.push_back(h.back());
    cout<<sol(0);
    return 0;
}

Measured memory_bytes: 7544
/*
      author  : nishi5451
      created : 14.08.2020 23:15:15
*/

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;


int main(){
    int s;
    cin >> s;
    map<int,int> mp;
    int index = 1;
    int value = s;
    while(1){
        if(mp[value]){
            cout << index << endl;
            return 0;
        }
        else{
            mp[value]++;
        }
        index++;
        if(value%2==0){
            value = value/2;
        }
        else{
            value = 3*value+1;
        }
        //cout << index << "-" << value << endl;
    }
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <string>
using namespace std;
int main(){
	char s[101];
	int cnt = 0;
	scanf("%s",s);
	int slen = strlen(s);
	for(int i = 0;i < slen;i++){
		if(s[i] != s[slen - 1 - i]){
			cnt++;
		}
	}
	printf("%d\n",cnt / 2);
}

Measured memory_bytes: 3836
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long K = sc.nextLong();
		long[] A = new long[N];
		long[] F = new long[N];
		Arrays.setAll(A, i -> sc.nextInt());
		Arrays.setAll(F, i -> sc.nextInt());
		Arrays.sort(A);
		Arrays.sort(F);
		long lb = 0, ub = 1000000000000L;
		do {
			long mid = (ub+lb)/2;
			long c = 0;
			for(int i = 0; i < N; i++)
				if(mid < A[i]*F[N-1-i])
					c += A[i]-mid/F[N-1-i];
			if(c > K)
				lb = mid+1;
			else
				ub = mid;
		}while(lb < ub);
		System.out.println(ub);
	}

}

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

int digit(LL num){
	int res = 0;
	while(num > 0) {
		res++;
		num /= 10;
	}
	return res;
}



int main(){
	LL N;cin >> N;
	int ans = 10;
	for(LL i = 1; i * i <= N; i++){
		LL a = 0, b = 0;
		if (N % i == 0) {
			a = i; b = N / i;
			if(a >= b) ans = min(ans, digit(a));
			else       ans = min(ans, digit(b));
		}
	}
	cout << ans << endl;


}














Measured memory_bytes: 3616
#include <stdio.h>
#include <math.h>
int main(){
    int n,i,pt=0,ph=0;
    char ct[101],ch[101];
    scanf("%d",&n);
    for (i=0;i<n;i++){
        scanf("%s %s",&ct,&ch);
        if (strcmp(ct,ch)>0){
            pt+=3;
        }else if (strcmp(ct,ch)<0){
            ph+=3;
        }else{
            pt++;ph++;
        }
    }
    printf("%d %d\n",pt,ph);
    return 0;
}   


Measured memory_bytes: 2148
#include<stdio.h>
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INF 100000

int A[101][101];
int d[101];
int color[101];
int pi[101];
int n;

int main(){
  int i,j,mincost,u,sum=0,v=0;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    d[i]=INF;
    color[i]=WHITE;
    pi[i]=-1;
    for(j=1;j<=n;j++){
      scanf("%d",&A[i][j]);
    }
  }
  /*  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      printf("%d",A[i][j]);
    }
    printf("\n");
    }*/
  d[1]=0;
  while(1){
    mincost=INF;
    for(i=1;i<=n;i++){
      for(j=1;j<=n;j++){
	if(A[i][j]!=-1){
	  if(color[i]!=BLACK && d[i]<mincost){
	    mincost=d[i];
	    /*   printf("mincost=%d\n",mincost);*/
	    u=i;
	  }
	}
      }
    }
	if(mincost==INF) break;
	color[u]=BLACK;
	for(i=1;i<=n;i++){
	  if(A[u][i]!=-1){
	    if(color[i]!=BLACK && A[u][i]<d[i]){
	      pi[i]=u;
	      d[i]=A[u][i];
	    }
	  }
	}
  }
    for(i=1;i<=n;i++){
      /* printf("d[%d]=%d\n",i,d[i]);*/
    sum+=d[i];
  }
  printf("%d\n",sum);
    
  return 0;
}
      
	    
	
			
  



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

int main()
{
	long long  a, b, c, d;
	long long  max;

	cin >> a >> b >> c >> d;

	max = b * d;

	if(max < a*c)
		max = a * c;

	if (a * d > max)
		max = a * d;

	if (max < b * c)
		max = b * c;

	if (max < b * d)
		max = b * d;

	cout << max << endl;

}

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

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

	int A, B, C;
	cin >> A >> B >> C;
	if (A <= C && C <= B) {
		cout << "Yes";
	}
	else cout << "No";
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

void solveSingleCase(int caseNo)
{
    int N, K;
    cin >> N >> K;
    VEC(int) Counts(N + 1, 0);
    FOR(i, 0, N) {
        int a;
        cin >> a;
        Counts[a]++;
    }

    sort(ALL(Counts), greater<int>());
    int ret = 0;
    if (K < N && Counts[K] > 0) {
        FOR(k, K, N + 1)
            ret += Counts[k];
    }
    cout << ret << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};


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

const int MAX = 100;
const int WIDTH = 2;

int main() {
	int N, A[WIDTH][MAX];
	cin >> N;
	for (int i = 0;i < WIDTH;i ++) for (int j = 0;j < N;j ++) cin >> A[i][j];
	int sum[WIDTH][MAX];
	for (int i = 0;i < WIDTH;i ++) sum[i][0] = A[i][0];
	for (int i = 0;i < WIDTH;i ++) for (int j = 1;j < N;j ++)sum[i][j] = sum[i][j - 1] + A[i][j]; // 累積和
	int max = sum[0][0] + sum[1][N - 1];
	for (int i = 1;i < N;i ++) { // iの位置で下に降りるとする
		if (max < sum[0][i] + sum[1][N - 1] - sum[1][i - 1]) max = sum[0][i] + sum[1][N - 1] - sum[1][i - 1];
	}
	cout << max;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

この問題では右と下にしか移動しないので、下へ移動は1回しか行わないことが分かる
ここで、ある地点yで下に移動するとする
その時、回収する飴は(1,1)から(1,y)と(2,y)から(2,N)の飴の総和
今、f(x,y)はf(x,1)からf(x,y)までの飴の総和であるとすると、f(x,y)=f(x,y-1)+A(x,y)であることと
回収する飴はf(1,y)+f(2,N)-f(2,y-1)で求められることから、累積和で解けることが分かる
計算量は累積和にO(N)、計算にO(N)なのでO(N)
*/

Measured memory_bytes: 256
#include <iostream>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
typedef long double ld;
using ll=long long;
using namespace std;
const auto mod=1e9+7;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n ; cin >> n;
  ll ans=0;
  for(ll i=1;i<=n;++i ){
  	if(i%3 !=0 and i%5!=0) ans+=i;
  }
  cout << ans << endl;
 }

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int c[200005];
vector<long long> G[200005];
long long path_num[200005];
long long ch_num[200005];
long long n;
long long ans;
long long dfs(long long u,long long v){
	long long pre = ch_num[c[u]];
	long long cnt_ch_num = 1;
	long long update = ch_num[c[u]];
	for(auto i:G[u]){
		if(i!=v){
			long long cntt = dfs(i,u);
			cnt_ch_num += cntt;
			long long delta = ch_num[c[u]] - update;
			long long k = cntt - delta;
			path_num[c[u]] += (k+1)*k/2;
			update = ch_num[c[u]];
		}
	}
	
	
	ch_num[c[u]] = pre + cnt_ch_num;
	return cnt_ch_num;
}
int main(){
	//freopen("in.txt","r",stdin);
	cin>>n;
	for(long long i=0;i<n;i++) {
		cin>>c[i];
		c[i]--;
	}
	
	long long t1,t2;
	for(long long i=0;i<n-1;i++){
		cin>>t1>>t2;
		t1--;t2--;
		G[t1].push_back(t2);
		G[t2].push_back(t1);
	}
	
	dfs(0,-1);
	for(long long i=0;i<n;i++){
		if(i!=c[0]){
			long long k=n-ch_num[i];
			ans = (n+1)*n/2 - path_num[i] - (k+1)*k/2;
		}
		else ans = (n+1)*n/2 - path_num[i];
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 34040
#include<stdio.h>

int main()
{
    int R;
    scanf("%d",&R);
    if(R<1200&&R>=0)
        printf("ABC");
    else if(R>=1200&&R<2800)
        printf("ARC");
        else if(R>=2800&&R<=4208)
        printf("AGC");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N,sum=0;
    string S;
    cin>>N;
    cin>>S;
    for(int i=0;i<N;++i){
        if(i!=N){
            if(S.substr(i,1)!=S.substr(i+1,1)){
                ++sum;
            }
        }else{
            ++sum;
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 512