akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")
 
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
 
 typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
 
//#define int         long long
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define mp          make_pair
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
//#define hell          1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
// mp::cpp_int
 
const int hell= 1000000007;
 
 int power(int a,int b)
 {
  if(b==0)return 1LL;
  if(b==1)return a;
  int t=power(a,b/2);
  t*=t;
  t%=hell;
  if(b&1)return (t*a)%hell;
  else return t;
 }

 int inverse(int a)
 {
    return power(a,hell-2);
 }
 
int pw(int a,int b)
{
  int x=a;
  rep(i,1,b){a=a*x;
    a%=10000000000LL;}
  return a;
}
 
int gcd(int a,int b)
{   
  if(b==0)return a;
  return gcd(b-a%b,a%b);
} 



int solve()
{

 string a,b;
 cin>>a>>b;
 int n=a.size(),m=b.size();
 int f[n+1][m+1][3];

rep(i,0,n+1)
{
  rep(j,0,m+1)
  {
    if(i==0||j==0){
      f[i][j][0]=0;
      f[i][j][1]=0;
      f[i][j][2]=0;
    }
    else if(a[i-1]==b[j-1])
      {
        f[i][j][0]=f[i-1][j-1][0]+1;
        f[i][j][1]=i-1;
        f[i][j][2]=j-1;
      }
    else 
      {
        if(f[i-1][j][0]>f[i][j-1][0])
        {
          f[i][j][0]=f[i-1][j][0];
          f[i][j][1]=f[i-1][j][1];
          f[i][j][2]=f[i-1][j][2];
        }
        else
        {
          f[i][j][0]=f[i][j-1][0];
          f[i][j][1]=f[i][j-1][1];
          f[i][j][2]=f[i][j-1][2];
        }  
      }
  }
}

int k=f[n][m][0];
int i=n,j=m;
 string ans="";
while(k!=0)
{
  int x=f[i][j][1];
  int y=f[i][j][2];
  i=x,j=y;
  ans+=a[i];
  k--;
}
reverse(all(ans));
cout<<ans;

 
return 0;
}
 
signed main()
{  int t=1;
//pri();
 ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
  
   cin.exceptions(cin.failbit);                                                                    
     
                               
   
 
  clock_t time_req;
 
    // Without ung pow function
                                                                                                                   
// cin>>t;
 
    int k=1;
     
   while(t--)
     {
      //cout<<"Case #"<<k<<":"<<" ";k++;
      solve();
     }
        exit(0);
 
         time_req = clock() - time_req;
    cout <<endl<< "Processor time taken is "
      << (double)time_req/CLOCKS_PER_SEC << " seconds" << endl;
 
 
    return 0;
 
  }


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


int main() {
  string s;
  cin >> s;
  string ss =s;
  reverse(s.begin(),s.end());
  int l = (s.length()-1)/2;
  string p="",pp;
  for(int i=0;i<l;i++) {
      p+=ss[i];
  }
  pp = p;
  reverse(pp.begin(),pp.end());
  
  if(s == ss && p == pp) cout << "Yes" <<endl;
  else cout << "No" << endl;
  
}


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

using namespace std;
typedef unsigned int uint;
typedef long long int ll;
typedef unsigned long long int ull;

#define debugv(v) printf("L%d %s => ",__LINE__,#v);for(auto e:v){cout<<e<<" ";}cout<<endl;
#define debugm(m) printf("L%d %s is..\n",__LINE__,#m);for(auto v:m){for(auto e:v){cout<<e<<" ";}cout<<endl;}
#define debuga(m,w) printf("L%d %s is => ",__LINE__,#m);for(int x=0;x<(w);x++){cout<<(m)[x]<<" ";}cout<<endl;
#define debugaa(m,w,h) printf("L%d %s is..\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){cout<<(m)[x][y]<<" ";}cout<<endl;}
#define ALL(v) (v).begin(),(v).end()
#define BIGINT 0x7FFFFFFF
#define E107 1000000007
void printbit(int u){if(u==0)cout<<0;else{int s=0,k=0;for(;0<u;u>>=1,k++)s=(s<<1)|(u&1);for(;0<k--;s>>=1)cout<<(s&1);}}

#define TIME chrono::system_clock::now()
#define MILLISEC(t) (chrono::duration_cast<chrono::milliseconds>(t).count())

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

int main(){
    int i,j,k,l;
    
    int n;
    string str;
    
    cin >> str;
    n = str.size();
    
    int count = 0;
    
    for (i=1;i<n;i++){
        if (str[i-1]=='W' && str[i]=='B'){
            count++;
        }
        if (str[i-1]=='B' && str[i]=='W'){
            count++;
        }
    }
    
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
	while ( true )
	{
		int x, h;
		cin >> x >> h;

		if ( x == 0 && h == 0 )
		{
			break;
		}

		double area = x * x;
		area += 2 * sqrt( pow( x / 2.0, 2 ) + pow( h, 2 ) ) * x;

		printf("%.6lf\n", area );
	}

	return 0;
}

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

ll k , x , d , ans ;

int main(){
  cin >> x >> k >> d ;
  if(x < 0) x = -1 * x ;
  ll syou = x / d ;
  ll sa = k - syou ;
  if(syou <= k && sa % 2 == 0) ans = x - syou * d ;
  else if(syou <= k && sa % 2 != 0) ans = -1 * (x - d - syou * d) ;
  else if(syou > k) ans =  x - k * d ;
  cout << ans << endl ;
}

Measured memory_bytes: 3632
H,W = map(int,input().split())
src = [input() for i in range(H)]

ans = []
for row in src:
    ans.append(list(row))

dxy = [(-1,-1),(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1)]
for y in range(H):
    for x in range(W):
        if src[y][x] == '#': continue
        c = 0
        for dx,dy in dxy:
            if x+dx < 0 or x+dx > W-1 or y+dy < 0 or y+dy > H-1: continue
            if src[y+dy][x+dx] == '#': c += 1
        ans[y][x] = c

for row in ans:
    print(''.join(list(map(str,row))))


Measured memory_bytes: 3064
from collections import Counter

N = int(input())
D = list(map(int, input().split()))

L = sorted(set(D))
d = Counter(D)
s = 0

if (D[0] == 0) and (list(range(max(D) + 1)) == L):
    if (d[0]==1) and (1 in d):
        s = 1
        for l in L[1:-1]:
            for i in range(d[l + 1]):
                s *= d[l]
                s %= 998244353
print(s)

Measured memory_bytes: 23644
#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 28;
inline void chmin(int &a, int b) { a = min(a, b); }

int H, W;
int dp[1005][1005][1 << 4];
int data[1005][1005] = {};

int main()
{
    fill_n(**dp, 1005 * 1005 * 16, INF);
    cin >> H >> W;
    for(int i = 1; i <= H; i++) {
        for(int j = 1; j <= W; j++) {
            char ch;
            cin >> ch;
            if(ch != '.') data[i][j] = ch - '0';
        }
    }

    dp[1][1][0] = 0; //0 = とってある 1 = とってない
    for(int i = 1; i <= H; i++) {
        for(int j = 1; j <= W; j++) {
            for(int k = 0; k < (1 << 4); k++) {
                int val; 
                if(dp[i][j][k] == INF) continue;
                //右
                if(j < W) {
                    int shift = (((k >> 2) & 1) << 3) | (1 << 1);
                    int a = data[i - 1][j + 1] * ((k >> 1) & 1), b = data[i][j + 2], c = data[i + 1][j + 1];
                    val = (k & 1) * data[i][j + 1] + dp[i][j][k] + a + b + c;
                    chmin(dp[i][j + 1][shift], val - a);
                    chmin(dp[i][j + 1][shift | 1], val - b);     //下
                    chmin(dp[i][j + 1][shift | (1 << 2)], val - c);  //右
                }
                //下
                if(i < H) {
                    int shift = ((k & 1) << 1) | (1 << 3);
                    int a = data[i + 1][j - 1] * ((k >> 3) & 1), b = data[i + 2][j], c = data[i + 1][j + 1];
                    val = ((k >> 2) & 1) * data[i + 1][j] + dp[i][j][k] + a + b + c;
                    chmin(dp[i + 1][j][shift], val - a);
                    chmin(dp[i + 1][j][shift | (1 << 2)], val - b);
                    chmin(dp[i + 1][j][shift | 1], val - c);
                }
            }
        }
    }
    int minv = INF;
    for(int i = 0; i < (1 << 4); i++) {
        chmin(minv, dp[H][W][i]);
    }
    cout << minv << endl;
    return (0);
}

Measured memory_bytes: 70108
import java.text.DecimalFormat;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        
        AtCoder problem = new AtCoder(sc);
        problem.solve(out);
        
        out.flush();
    }
    
}

class AtCoder {
    final int A,B;
    AtCoder(FastScanner sc) {
        A = sc.nextInt();
        B = sc.nextInt();
    }

    void solve(PrintWriter out) {
        final int C = (A+B) / 2;
        out.println(Math.abs(A - C) == Math.abs(B - C) ? C : "IMPOSSIBLE");
    }
    
}

// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
class FastScanner {
    
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    
    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }
    
    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
    
    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }
    
    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    
    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }
    
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21588
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;

int main()
{
      int n,k,s[110],sum[110],a,i,j;
      while(scanf("%d%d",&n,&k)&&(n||k))
      {
            memset(sum,0,sizeof(sum));
            for(j=1;j<=k;j++) scanf("%d",&s[j]);
            for(j=1;j<=n;j++)
            {
                  for(i=1;i<=k;i++)
                  {
                        scanf("%d",&a);
                        sum[i]+=a;
                  }
            }
            bool ok=1;
            for(i=1;i<=k;i++) if(s[i]<sum[i]) ok=0;
            if(ok) printf("Yes\n");
            else printf("No\n");
      }
      return 0;
}

Measured memory_bytes: 736
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>

int main() {
	int i = 0;
	int count;
	int x[10000];
	int y[10000];

	while (1) {
		std::cin >> x[i] >> y[i];
		if (x[i] == 0 && y[i] == 0) {
			count = i;
			break;
		}
		i++;
	}

	for (i = 0; i < count; i++) {
		if (x[i] > y[i]) {
			std::cout << y[i] << " " << x[i] << std::endl;
		}
		else {
			std::cout << x[i] << " " << y[i] << std::endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3088
#include <cstdio>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

int N;

int main()
{
  scanf( "%d", &N );

  printf( "%d\n", (N+1)/2 );

  return 0;
}

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

int main()
{
    int n,m;
    cin >> n >> m;
    vector< pair<int,int> > p;
    for( int i = 0; i < m; ++i )
    {
        int a,b;
        cin >> a >> b;
        p.push_back(make_pair(b,a));
    }

    sort(p.begin(),p.end());
    int z = 0; int ans = 0;
    for( int i = 0; i < m; ++i )
    {
        if( z <= p.at(i).second )
        {
            z = p.at(i).first;
            ans++;
        }
    }

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



Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
long long n,a,b,c,x,t = 1;
int main()
{
	cin >> a >> b >> c;
	x = b * 10 + c;
	if (x % 4 == 0) cout << "YES\n";
		else cout << "NO\n";
 	return 0;
 } 

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

using ll = long long;
const char dx[9] = { 1,1,1,0,0,0,-1,-1,-1 }, dy[9] = { 1,0,-1,1,0,-1,1,0,-1 };

ll h, w, n, a, b, cnt, x, y, nx, ny, nnx, nny, sum, ans[10];
char j, k;
vector<ll>v;
unordered_map<ll, bool>mp;
signed main() {
	scanf("%lld %lld %lld", &h, &w, &n);
	rep(i, n) {
		scanf("%lld %lld", &a, &b);
		--a; --b;
		v.emplace_back(w * a + b);
	}
    sort(all(v));
	for (ll i : v) {
		y = i / w, x = i % w;
		for (j = 0; j < 9; ++j) {
			nx = x + dx[j], ny = y + dy[j];
			if (0 < nx && nx < w - 1 && 0 < ny && ny < h - 1) {
				if (!mp[w * ny + nx]) {
					mp[w * ny + nx] = true;
					for (k = 0; k < 9; ++k) {
						nnx = nx + dx[k], nny = ny + dy[k];
						if (binary_search(all(v), w * nny + nnx)) {
							++cnt;
						}
					}
					++ans[cnt];
					++sum;
					cnt = 0;
				}
			}
		}
	}
	ans[0] += (h - 2) * (w - 2) - sum;
	for (ll i : ans) {
		printf("%lld\n", i);
	}
}


Measured memory_bytes: 37472
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 100010;
const int MAXK = 510;
const int MAXQ = 200010;

int a[MAXN], n;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    FOR(i,1,n) cin >> a[i];
    sort(a+1, a+n+1);
    cout << a[n] - a[1];
    return 0;
}

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

int main(){
    int n; cin >> n;
    vector<int> p(n);
    vector<int> m(n);
    for(int i = 0; i < n; i++) cin >> p[i];
    m[0] = p[0];
    ll ans = 0;
    for(int i = 1; i < n; i++){
        m[i] = min(m[i-1], p[i]);
    }
    for(int i = 0; i < n; i++){
        if(p[i] <= m[i]) ans++;
    }
    cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD
string s;
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>s;
    int n = s.size();
    
    vi cs(n+2);
    cs[0] = 0;
    REP(i,n){
        cs[i+1] = cs[i] + ((s[i]=='B')?1:0);
    }

    //DEBUG_VEC(cs);

    ll ans = 0;
    REP(i,n){
        if(s[i]=='W'){
            ans += cs[i+1];
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a == b){
    if(a == c){
      cout << "No" << endl;
    }
    else{
      cout << "Yes" << endl;
    }
  }
  else if(a == c){
    cout << "Yes" << endl;
  }
  else if(b == c){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}





Measured memory_bytes: 256
// Date: 2020-03-17

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define FIO ios::sync_with_stdio(false);cin.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)x.size())
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

#define mid ((l+r)>>1)
#define lc rt << 1
#define rc rt << 1 | 1
#define lson lc, l, mid
#define rson rc, mid + 1, r

int n, m;
LL mx[N<<2], add[N<<2], sum[N];

void pd(int rt) {
    if(add[rt]) {
        add[lc] += add[rt], mx[lc] += add[rt];
        add[rc] += add[rt], mx[rc] += add[rt];
        add[rt] = 0;
    }
}

void pushup(int rt) {
    mx[rt] = max(mx[lc], mx[rc]);
}

void update(int rt, int l, int r, int ql, int qr, LL v) {
    if(ql <= l && r <= qr) {
        mx[rt] += v;
        add[rt] += v;
        return;
    }
    pd(rt);
    if(ql <= mid) update(lson, ql, qr, v);
    if(qr > mid) update(rson, ql, qr, v);
    pushup(rt);
}

LL ask(int rt, int l, int r, int x) {
    if(l == r) return mx[rt];
    pd(rt);
    if(x <= mid) return ask(lson, x);
    else return max(mx[lc], ask(rson, x));
}

struct seg {
    int l, r, v;
    bool operator < (const seg& rhs) const {
        if(r != rhs.r) return r < rhs.r;
        return l < rhs.l;
    }
} s[N];

LL dp[N];
int main() {
    FIO;
    cin >> n >> m;
    rep(i, 1, m) {
        cin >> s[i].l >> s[i].r >> s[i].v;
        sum[s[i].r] += s[i].v;
    }
    sort(s+1, s+1+m);
    int cur = 1;
    rep(i, 1, n) {
        update(1, 1, n, i, i, ask(1, 1, n, i));
        while(s[cur].r == i) {
            update(1, 1, n, s[cur].l, s[cur].r, s[cur].v);
            cur++;
        }
    }
    LL ans = max(0LL, mx[1]);
    cout << ans;

    return 0;
}

Measured memory_bytes: 15104
/*
    Problem 33
    https://atcoder.jp/contests/abc088/tasks/abc088_d
*/
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
vector<int> dx = {0, 0, 1, -1};
vector<int> dy = {1, -1, 0, 0};
/* function */
/* main */
int main(){
    int h, w;
    cin >> h >> w;
    vector<vector<bool>> grid(h, vector<bool>(w));
    int ans = h * w;
    for (int i = 0; i < h*w; i++) {
        char c; cin >> c;
        grid[i/w][i%w] = c == '.';
        ans -= (c == '#');  // 黒マスの分あらかじめ引いとく
    }

    vector<vector<int>> dist(h, vector<int>(w, 0));
    queue<pii> q;
    q.emplace(0, 0);
    dist[0][0] = 1;
    while(!q.empty()) {
        pii p = q.front(); q.pop();
        int x = p.first, y = p.second;
        for (int i = 0; i < dx.size(); i++) {
            int nx = x + dx[i], ny = y + dy[i];
            if (nx < 0 || h <= nx || ny < 0 || w <= ny) continue;
            if (!grid[nx][ny] || dist[nx][ny] != 0) continue;
            dist[nx][ny] = dist[x][y] + 1;
            q.emplace(nx, ny);
        }
    }
    cout << ((dist[h-1][w-1] == 0) ? -1 : ans - dist[h-1][w-1]) << '\n';
}

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

int main(){
  long int h, n, a, total=0;
  cin >> h >> n;
  rep(i,n){
    cin >> a;
    total += a;
  }
  cout << (total>=h?"Yes":"No") << endl;
  return 0;
}


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

#define readv(v) for(auto& kaka : v) cin >> kaka;

using ll = long long int;
using vi = vector<ll>;
using vvi = vector<vi>;

int n, k;
vi comb;
const ll MOD = 1000000007;

ll power(ll b, ll e){
    if (e == 1) return b%MOD;
    else if (e%2 == 0) return (power(b*b%MOD, e/2));
    else return b*power(b,e-1)%MOD;
}

ll inverse(ll k){
    return power(k, MOD-2);
}

// Returns value of Binomial Coefficient C(n, k)  
void fill(){  
    comb[k-1] = 1;
    for (int i = k; i < n; i++) {
        (comb[i] = comb[i-1] * i) %= MOD;
        (comb[i] *= inverse(i-k+1)) %= MOD;
    }   
}  

int main(){
    cin >> n >> k;
    comb = vi(n, 0);
    fill();
    vi a(n); readv(a);
    sort(a.begin(), a.end());
    ll sum = 0;
    for (int i = 1; i <= n; i++) {
        //cout << (2 * comb[n-i-1] - comb[n-1]) << endl;
        sum += (a[i-1] * (comb[i-1] - comb[n-i])) % MOD;
        sum %= MOD;
    }
    cout << sum << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define fr(i,s,e) for(i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;

const int mxn=2e5+1;

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

  int t=1;
  //cin>>t;
  int tt=1;
  while(t--){
    int n,m;
    cin>>n>>m;
    int mx=1,mn=n;
    int i;
    pair<int,int> arr[n];
    fr(i,0,m)
    {
      int l,r;
      cin>>l>>r;
      arr[i]={l,r};
      
       //cout<<"Case #"<<tt<<": ";
       //tt++;
    }
    sort(arr,arr+m);
    fr(i,0,m)
    {
      int l=arr[i].fi;
      int r=arr[i].se;
      if(l>mn or r<mx)
      {
        cout<<0;
        return 0;
      }
      mx=max(mx,l);
      mn=min(mn,r);
    }
    int ans=max(0,mn-mx+1);
    cout<<ans;
    }
  return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    char c;
    cin >> c;
    cout << (char)(c + (char)1) << "\n";

    return 0;
}



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


typedef long long ll;

const ll INF = (1LL << 60);

ll a, b, c;
int x, y;

int main(){
    cin >> a >> b >> c >> x >> y;

    ll res = INF;

    int n = max(x, y);
    for (int i = 0; i <= n; i++){
        ll cnt_a = 0; 
        ll cnt_b = 0; 
        ll cnt_c = 0;
        if (x - i >= 0) cnt_a = x-i;
        if (y - i >= 0) cnt_b = y-i;
        cnt_c = i*2;
        res = min(res, a*cnt_a + b*cnt_b + c*cnt_c);
    }
    
    cout << res << endl;
}

// 5000 5000 4999 1 100000

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int)N;i++)
#define p(s) cout<<(s)<<endl
#define ck(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf=1e9;


int main(){
	int N,M;
	cin>>N>>M;
	vector<int> vt[100];
	REP(i,0,M){
		int a,b;
		cin >>a>>b;
		a--;b--;
		vt[a].push_back(b);
		vt[b].push_back(a);
	}
	REP(i,0,N){
		p(vt[i].size());
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    string s, t; cin >> s >> t;
    bool flg = false;

    for(int i=0; i<s.size(); i++){
        bool match = true;
        for(int j=0; j<s.size(); j++){
            if(s[(i+j)%s.size()] != t[j]) match = false;
        }
        if(match){
            flg = true;
            break;
        }
    }

    if(flg) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

class UnionFind:
    def __init__(self, size):
        self.parent = list(range(size))
        self.rank = [0] * size

    def find(self, x):
        if self.parent[x] != x:
            self.parent[x] = self.find(self.parent[x])
        return self.parent[x]
        
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        else:
            self.parent[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)

N = int(input())
S = [input().rstrip() for _ in range(N)]
uf = UnionFind(N)
for i in range(N):
    for j in range(i):
        if S[i][j] == '1':
            uf.unite(i, j)
depth = defaultdict(int)
for i in range(N):
    color = [-1] * N
    queue = deque()
    queue.append((i, 1))
    color[i] = 0
    max_d = 1
    while queue:
        j, d = queue.popleft()
        max_d = max(max_d, d)
        for k in range(N):
            if k == j or S[j][k] == '0':
                continue
            if color[k] == -1:
                color[k] = 1 - color[j]
                queue.append((k, d+1))
            elif color[k] == color[j]:
                print(-1)
                exit()
    depth[uf.find(i)] = max(depth[uf.find(i)], max_d)
ans = sum(depth[i] for i in range(N))
print(ans)

Measured memory_bytes: 45276
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i)
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 2e18+5;
const int nax = 1<<12;
const int mxm = 1001;
int dp[nax],locks[mxm],cost[mxm],n,m,sz,l;
void solve()
  {
   cin>>n>>m;
   loop(i,0,m)
    {
      cin>>cost[i]>>sz;
      loop(j,0,sz)
       {
        cin>>l;
        l--;
        locks[i] |= (1<<l);
       }
    }
   dp[0] = 0;
   loop(i,1,(1<<n))
    {
      dp[i] = inf;
      loop(j,0,m)
       {
        int left = (i^locks[j])&i;
        dp[i] = min(dp[i],dp[left]+cost[j]);
       }
    }
  if(dp[(1<<n)-1] == inf)
     dp[(1<<n)-1] = -1;
   cout<<dp[(1<<n)-1];
  }
signed main()
 {
   
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 
    solve();    
  //cerr<<END<<1.0*clock();
  return 0;
} 

Measured memory_bytes: 3664
#include <iostream>
#include <algorithm>
#include <vector>

#include <cstdio>
#include <cmath>
using namespace std;

typedef double D;
const D EPS = 1e-8;
const D INF = 1e10;
const D PI = M_PI;

struct P {
    D x, y;
    P(D xs, D ys) : x(xs), y(ys) { }
    P() { }
};

P operator +(P a, P b) { return P(a.x + b.x, a.y + b.y); }
P operator -(P a, P b) { return P(a.x - b.x, a.y - b.y); }
P operator *(P p, D s) { return P(p.x * s, p.y * s); }

D inp(P a, P b) { return a.x*b.x + a.y*b.y; }
D outp(P a, P b) { return a.x*b.y - a.y*b.x; }

D norm(P p) { return inp(p, p); }
D abs(P p) { return sqrt(norm(p)); }

bool eq(P a, P b) { return abs(a - b) < EPS; }

D arg(P p) { return atan2(p.y, p.x); }

P rot90(P p) {
    return P(-p.y, p.x);
}

P rot(P p, D radian) {
    P q;
    q.x = cos(radian)*p.x - sin(radian)*p.y;
    q.y = sin(radian)*p.x + cos(radian)*p.y;
    return q;
}

struct L : vector<P> {
    L(P a, P b) { push_back(a); push_back(b); }
    L() { this->resize(2); }
};

struct C {
    P p; D r;
    C(P ps, D rs) : p(ps), r(rs) { }
    C() { }
};

// ??卒???l???????????????p?????????
// (l??????p??????????????????????????即????????????????賊???????)
// norm??則?????贈?????????(abs??則??????????????????)
P projection(L l, P p) {
    P a = l[1] - l[0];
    P b = p - l[0];
    D t = inp(b, a) / norm(a);
    return l[0] + a * t;
}

// ??卒???l???????????????p???????属?
// (l????????????????則属???p??????)
P reflection(L l, P p) {
    return p + (projection(l, p) - p) * 2;
}

int ccw(P a, P b, P c) {
    b = b - a; c = c - a;

    // a - b - c ????????????????????即???
    if(outp(b, c) > EPS)  return +1; // ???????即???????
    if(outp(b, c) < -EPS) return -1; // ????即???????

    // a - b - c ??卒??????????????其??即???
    if(inp(b, c) < 0)     return +2; // c - a - b
    if(norm(b) < norm(c)) return -2; // a - b - c
    return 0;                        // a - c - b
}

/* intersect Segment Segment */
bool iSS(L s, L t) {
    return ccw(s[0], s[1], t[0]) * ccw(s[0], s[1], t[1]) <= 0 &&
        ccw(t[0], t[1], s[0]) * ccw(t[0], t[1], s[1]) <= 0;
}

/* intersect Segment Point */
bool iSP(L s, P p) {
    return ccw(s[0], s[1], p) == 0;
}

/* distance Segment Point */
D dSP(L s, P p) {
    P r = projection(s, p);
    if(iSP(s, r)) return abs(r - p);
    return min(abs(s[0] - p), abs(s[1] - p));
}

/* distance Segment Segment */
D dSS(L s, L t) {
    if(iSS(s, t)) return 0;
    return min(min(dSP(s, t[0]), dSP(s, t[1])),
            min(dSP(t, s[0]), dSP(t, s[1])));
}

/* crosspoint Line Line */
/* ?????????????????即??????iSS(s,t)????蔵???????????????即 */
P cLL(L l, L m) {
    D d = outp(m[1] - m[0], l[1] - l[0]);
    if(abs(d) < EPS) throw "s // t !";
    return l[0] + (l[1] - l[0]) * outp(m[1] - m[0], m[1] - l[0]) * (1.0 / d);
}


int main() {
    int Q; cin >> Q;
    while(Q--) {
        D x[4], y[4];
        for(int i = 0; i < 4; i++) {
            cin >> x[i] >> y[i];
        }

        L s(P(x[0], y[0]), P(x[1], y[1])), t(P(x[2], y[2]), P(x[3], y[3]));

        D d = dSS(s, t);
        printf("%.9f\n", d);
    }
}

Measured memory_bytes: 1248
#include <iostream>
#include <algorithm>

int N, K, A[1001];

int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);
  std::cout.tie(NULL);

  std::cin >> N >> K;
  for (int i = 0; i < N; ++i)
    std::cin >> A[i];

  std::sort(A, A+N);

  int ans = 0;
  for (int i = 0; i < K; ++i)
    ans += A[i];

  std::cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 3636
def get_sieve_of_eratosthenes_new(n):
    import math
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]

prime=get_sieve_of_eratosthenes_new(10**6)

def ind(b,n):
    res=0
    while n%b==0:
        res+=1
        n//=b
    return res

N=int(input())
count={p:0 for p in prime}
for p in prime:
    a=ind(p,N)
    count[p]=a
    N//=p**a

if N!=1:
    count[N]=0
    count[N]=1

res=0
for p in count:
    if count[p]:
        t=(2*count[p])**0.5
        t=int(t)
        if 2*count[p]>=t*(t+1):
            res+=t
        else:
            res+=t-1

print(res)

Measured memory_bytes: 168572
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1<<30;
const ll MOD = 1000000007;

int main(void) {

    int x[5];
    rep(i, 5) {
        cin >> x[i];
    }
    rep(i, 5){
        if (x[i] == 0) {
            cout << i + 1 << endl;
            return 0;
        }
    }


    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}


int main() {
  ll n,k;
  cin >> n >> k;
  ll s=n/k;
  ll t=abs(n-s*k);
  ll w=abs(n-(s+1)*k);
  cout << min(t,w) << endl;
  
}

Measured memory_bytes: 256
// use proconio::marker::Chars;
use proconio::{fastout, input};
// use std::cmp::{max, min};

#[fastout]
fn main() {
    input! {
        n: usize
    };

    let x = (n - 1) / 111;
    println!("{}", (x + 1) * 111);
}


Measured memory_bytes: 2148
#include <iostream>
using namespace std;
void ABC150(void);
void ABC151(void);
void ABC152(void);
void ABC153(void);
void ABC154(void);
void ABC155(void);
void ABC156(void);
void ABC157(void);
void ABC158(void);
void ABC159(void);

int main(void){
    ABC157();
}

void ABC157(){
    int n;
    cin>>n;
    cout<<(n+1)/2<<endl;
}

Measured memory_bytes: 256
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();

    PriorityQueue<Integer> pq = new PriorityQueue(Collections.reverseOrder());
    for (int i = 0; i < N; i++) {
      int n = sc.nextInt();
      pq.offer(n);
    }

    for (int i = 0; i < M; i++) {
      if(pq.isEmpty()) break;
      int max = pq.remove();
      max = max /2;
      if(max >0){
        pq.offer(max);
      }
    }
    long ans = 0;
    while(!pq.isEmpty()){
      int n = pq.remove();
      ans += n;
    }

    System.out.println(ans);

   }

}


Measured memory_bytes: 61380
//#include <bits/stdc++.h>                          //include all library
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <sstream>
#include <vector>
#include <stack>
#include <queue>
#include <string.h>
#include <functional> // greater<int> はfunctionalヘッダ
using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)          //REP(i, 10){...} //i=0～i=9までのループ
#define REPR(i, n) for(int i = n;i >= 0;i--)        //REPR(i, 10){...} //i=10～i=0までのループ
#define FOR(i, m, n) for(int i = m;i < n;i++)       //FOR(i, 3, 10){...} //i=3～i=9までのループ
#define FORR(i, m, n) for(int i = m;i >= n;i--)     //FORR(i, 10, 3){...} //i=10～i=3までのループ
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
#define PI 3.141592653589
#define npos -1


int main(){
	int n, sum=0;
	cin >> n;
	vector<int> a(n);
	vector<int> s(n);

	for(int i=0; i<n; i++){
		cin >> a[i];
		sum += a[i];
		s[i] = sum;
	}

	int mini=INF;

	for(int i=0; i<n; i++){
		if(mini==min(mini, abs(s[i]*2-sum))){
			cout << mini << endl;
			break;
		} else{
			mini = min(mini, abs(s[i]*2-sum));
		}

	}
}

Measured memory_bytes: 256
program main
	implicit none
    integer :: n, x, kaisu, sum, i
    integer, allocatable :: l(:)
    read(*, *) n, x
    allocate(l(n))
    read(*, *) (l(i), i = 1, n)
    kaisu = 0
    sum = 0
    do while (sum.le.x .and. kaisu.le.n)
		kaisu = kaisu + 1
    	sum = sum + l(kaisu)
    enddo
    write(*, *) kaisu
stop
end program main

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#define pai 3.1415926535

int main(void) {
	char S[4];
	scanf("%s", S);
	char a[4];
	for (int i = 0; i < 3; i++) {
		if (S[i] == '1') {
			S[i] = '9';
		}
		else {
			S[i] = '1';
		}
	}
	
	printf("%s", S);
		return 0;
}


Measured memory_bytes: 128
n = input()
n = int(n)
a = input().split()
a = [int(aa) for aa in a]
 
ans = 10000000000000000
 
l = -100000000000
r =  100000000000
 
for count in range(100):
    mid1 = 1 * (r - l) // 3 + l
    mid2 = 2 * (r - l) // 3 + l
    temp1 = 0
    temp2 = 0
    for i in range(n):
        temp1 += abs(a[i] - (mid1 + i + 1))
        temp2 += abs(a[i] - (mid2 + i + 1))
    if temp1 < temp2:
        r = mid2
    else:
        l = mid1
for b in range(l, r + 1):
    temp = 0
    for i in range(n):
        temp += abs(a[i] - (b + i + 1))
    ans = min(ans, temp)
print(ans)

Measured memory_bytes: 86996
#include<iostream>
#include<map>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
using namespace std;
#define REP(i,b,e) for(int i=(int)b;i<(int)e;i++)
#define Rep(i,n) REP(i,0,n)
typedef long long ll;

int q;
string X,Y;

int main(){
    cin>>q;
    Rep(i,q){
        cin>>X>>Y;
        X= ' '+X;
        Y= ' '+Y;
        int m,n;
        int maxl=0;
        m=X.size();
        n=Y.size();
        int c[m+3][n+3];
        Rep(j,m)Rep(k,n) c[j][k]=0;
        REP(j,1,m){
            REP(k,1,n){
                if(X[j]==Y[k]) c[j][k]=c[j-1][k-1]+1;
                else c[j][k]=max(c[j-1][k],c[j][k-1]);
                maxl=max(maxl,c[j][k]);
            }
        }
        cout<<maxl<<endl;
    }
    return 0;
}


Measured memory_bytes: 7092
#include<iostream>

using namespace std;

int main() {

	int H, W,a;
	char mozi[100][100];

	cin >> H >> W;

	for (a = 0; a < H; a++) {

		for (int i = 0; i < W; i++) {

			cin >> mozi[a][i];

		}

	}

	for (int i = 0; i <= W + 1; i++) {

		cout << "#";

	}

	cout << endl;

	for (a = 0; a < H; a++) {

		cout << "#";

		for (int i = 0; i < W; i++) {

			cout << mozi[a][i];

		}

		cout << "#" << endl;

	}

	for (int i = 0; i <= W + 1; i++) {

		cout << "#";

	}

	cout << endl;

}

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

namespace AtTest.AGC_Challenge
{
    class _025_A
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            int sum = 0;
            while (n > 0)
            {
                sum += n % 10;
                n /= 10;
            }
            if (sum == 1)
            {
                sum = 10;
            }
            Console.WriteLine(sum);
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13140
# -*- coding: utf-8 -*-
import itertools
import sys
import math
from functools import lru_cache

# 1整数
# n = int(input())

# 空白区切り2変数
from queue import Queue
from operator import mul
from functools import reduce
from queue import Queue
from operator import mul
from functools import reduce
from functools import lru_cache

input = sys.stdin.readline

# N個整数
# a, b, c = list(map(int, input().split()))

# 1整数
# n = int(input())

# 空白区切りリスト整数
# b = list(map(int, input().split()))

# 空白区切り文字列
# t, d = input().split()


s = input()
l = len(s) - 1
r1 = 0
r2 = 0
for i in range(l):
    if i % 2 == 0:
        if s[i] != '0':
            r1 += 1
        else:
            r2 += 1
    if i % 2 == 1:
        if s[i] != '1':
            r1 += 1
        else:
            r2 += 1
print(min(r1, r2))


Measured memory_bytes: 4564
s = input()
atoz = "abcdefghijklmnopqrstuvwxyz"
if len(s) < 26:
  for i in atoz:
    if i not in s:
      print(s+i)
      break
else:
  for i in range(len(s)):
    si = s[i:]
    if si == "".join(sorted(si, reverse=True)):
      if i == 0:
        print(-1)
        exit()
      else:
        hoge = s[i - 1]
        moge = list(si)
        moge.sort()
        for j in moge:
          if j > hoge:
            print(s[:i-1]+j)
            exit()
  

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define pi 3.1415926535
int main(){
  int n;
  cin>>n;
  int t=n;
  int x=0;
  x+=t%10;
  while(t>=1){
    t/=10;
    x+=t%10;
  }
  if(n%x==0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			int a = sc.nextInt();
			String op = sc.next();
			int b = sc.nextInt();
			if(op.equals("?")) {
				break;
			}else if(op.equals("+")) {
				System.out.println(a + b);
			}else if(op.equals("-")) {
				System.out.println(a - b);
			}else if(op.equals("*")) {
				System.out.println(a * b);
			}else if(op.equals("/")) {
				System.out.println(a / b);
			}
			
			
		}
	
	}
}



Measured memory_bytes: 26180
using System;
class Program
{
  static void Main(string[] args)
  {
    string[] input = Console.ReadLine().Split(' ');
    int cost = int.Parse(input[0]);
    int money = int.Parse(input[1]);
    int max = int.Parse(input[2]);
    if(money / cost >= max) Console.WriteLine(max);
    else Console.WriteLine(money / cost);
  }
}

Measured memory_bytes: 13140
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String b = sc.next();
		if (b.equals("A")) {
			System.out.println("T");
		}
		if (b.equals("T")) {
			System.out.println("A");
		}
		if (b.equals("G")) {
			System.out.println("C");
		}
		if (b.equals("C")) {
			System.out.println("G");
		}
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N;
    string S,SS;
    cin >> N >> S;
    vector<vector<ll>> dp(N+1,vector<ll>(N+1));
    for(ll i=N-1;i>=0;i--){
        for(ll j=N-1;j>=0;j--){
            if(S[i] == S[j]){
                dp[i][j] = dp[i+1][j+1]+1;//min(dp[i+1][j+1]+1,abs(i-j));
            }
            //cmax(dp[i][j], dp[i+1][j]);
            //cmax(dp[i][j], dp[i][j+1]);
        }
    }
    ll ans = 0;
    rep(i,N){
        rep(j,N){
            if(j<=i)continue;
            cmax(ans, min(dp[i][j], ll(j-i)));
        }
    }
    cout << ans << endl;
    /*
    ll ans = 0;
    rep(ii,N){
        S = SS.substr(ii,N-ii);
        vector<ll> A(S.size());
        A[0] = S.size();
        int i = 1, j = 0;
        while (i < S.size()) {
            while (i+j < S.size() && S[j] == S[i+j]) ++j; // 右向きにjを伸ばしていく
            A[i] = j;
            if (j == 0) { ++i; continue;}
            int k = 1;
            while (i+k < S.size() && k+A[k] < j) A[i+k] = A[k], ++k; // i~j間にkを走らせる
            i += k; j -= k;
        }
        REP(l,1,A.size()){
            if(A[l] > l) continue;
            cmax(ans,A[l]);
        }
    }
    cout << ans << endl;*/
}

Measured memory_bytes: 198868
n=int(input())
s=[]
for i in range(n):
    a=input()
    b=[]
    for j in range(10):
        b.append(a[j])
    b.sort()
    c="".join(b)
    s.append(c)
s.sort()
ans=0
t=1
for i in range(1,n):
    if s[i]==s[i-1]:
        ans+=t
        t+=1
    else:
        t=1
print(ans)

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

int main() {
    ll h,w;
    std::cin >> h>>w;
    vector<vector<ll>> a(h,vector<ll>(w));
    vector<vector<ll>> b(h,vector<ll>(w));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            std::cin >> a[i][j];
        }
    }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            std::cin >> b[i][j];
        }
    }
    
    vector<vector<vector<bool>>> dp(h,vector<vector<bool>>(w,vector<bool>(7000,false)));
    
    dp[0][0][(int)abs(a[0][0]-b[0][0])] = true;
    
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            int x = (int)abs(a[i][j]-b[i][j]);
            for (int k = 0; k <= 6400; k++) {
                if(i>0 && dp[i-1][j][(int)abs(k-x)]){
                    dp[i][j][k] = true;   
                }
                if(i>0 && dp[i-1][j][k+x]){
                    dp[i][j][k] = true;   
                }
                if(j>0 && dp[i][j-1][(int)abs(k-x)]){
                    dp[i][j][k] = true;   
                }
                if(j>0 && dp[i][j-1][k+x]){
                    dp[i][j][k] = true;   
                }
            }
        }
    }
    for (int i = 0; i <= 6400; i++) {
        if(dp[h-1][w-1][i]){
            std::cout << i << std::endl;
            return 0;
        }
    }
}


Measured memory_bytes: 6272