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

signed main() {
  string S;
  cin >> S;
  int ans = 0,w=0;
  for(int i=0; i<S.size(); i++){
	  if(S[i] == 'W'){
		  ans+= i-w;
		  w++;
	  }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3768
n = int(input())
l = [int(i) for i in input().split()]
l2 = []
l3 = []
for i in range(n):
    l2.append([l[i],i+1])
l2.sort()
for i in range(n):
    l3.append(l2[i][1])
print(' '.join(map(str,l3)))


Measured memory_bytes: 28328
# -*- coding: utf-8 -*-
import sys

N, M, *AB = map(int, sys.stdin.buffer.read().split())

list_path = [[] for _ in range(N+1)]

for i in range(M):
  A,B = AB[2*i],AB[2*i+1]
  list_path[A].append(B)
  list_path[B].append(A)

list_bfs = [1]
list_flg = [0 for _ in range(N+1)]
list_flg[1] = 1

while len(list_bfs)>0:
  list_tmp = []
  for i in list_bfs:
    for j in list_path[i]:
      if list_flg[j]==0:
        list_tmp.append(j)
        list_flg[j] = i
  list_bfs = list_tmp

print('Yes')
for i in list_flg[2:]:
  print(i)

Measured memory_bytes: 46172
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
N = int(input())

Ans = 0
numlist = [0] * 10001

if int(float(N)**0.5) <= 1:
  rMax = 1
else:
  rMax = int(float(N)**0.5)  

for x in range(1,rMax+1):
  for y in range(1,rMax+1):
    for z in range(1,rMax+1):
      Ans = x**2 + y**2 + z**2 + (x * y) + (y * z) + (z * x)
      if Ans <= 10000:
        numlist[Ans] += 1
  
for r in range(1,N+1):
  print(numlist[r])


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

/*ソートの時に使う
int sort(const void *a, const void *b){
    return *(int*)a-*(int*)b ;
}
    qsort (data,sizeof(data),sizeof(int),sort); 
*/

int main(void){
    int a,b,c,d;
    char n[5],cmp[11]="0123456789";
    scanf("%s",n);
    for (int i=0; i<11; i++){
        if (n[0]==cmp[i]){
            a=i;
        }
        if (n[1]==cmp[i]){
            b=i;
        }
        if (n[2]==cmp[i]){
            c=i;
        }
        if (n[3]==cmp[i]){
            d=i;
        }
    }
    if (a+b+c+d==7){
        printf ("%d+%d+%d+%d=7\n",a,b,c,d);
        
    } else if (a+b+c-d==7){
        printf ("%d+%d+%d-%d=7\n",a,b,c,d);
        
    } else if (a+b-c+d==7){
        printf ("%d+%d-%d+%d=7\n",a,b,c,d);
        
    } else if (a+b-c-d==7){
        printf ("%d+%d-%d-%d=7\n",a,b,c,d);
        
    } else if (a-b+c+d==7){
        printf ("%d-%d+%d+%d=7\n",a,b,c,d);
        
    } else if (a-b+c-d==7){
        printf ("%d-%d+%d-%d=7\n",a,b,c,d);
        
    } else if (a-b-c+d==7){
        printf ("%d-%d-%d+%d=7\n",a,b,c,d);
        
    } else if (a-b-c-d==7){
        printf ("%d-%d-%d-%d=7\n",a,b,c,d);
        
    }
	return 0 ;
}

Measured memory_bytes: 128
'use strict';
function main(input) {
  const arr = input.trim().split('\n');
  const hp = arr[0].split(' ').map(x => Number(x));
  const attack = arr[1].split(' ').map(x => Number(x));
  let sum = 0;

  for (let i = 0; i < attack.length; i ++) {
    sum += attack[i];
  }
  
  console.log(sum >= hp[0] ? 'Yes' : 'No');
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 16716
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll N, M;
  cin >> N >> M;
  vl cities(N, 0);
  ll a, b;
  rep(i, M){
    cin >> a >> b;

    cities[a - 1]++;
    cities[b - 1]++;
  }

  rep(i, N) cout << cities[i] << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
  
	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++)cin >> a[i];
	int q;
	cin >> q;
	while(q--){
		int el;
		cin >> el;
		int pos = lower_bound(a, a + n, el) - a;
		cout << pos << '\n';
	}
    return 0;
}



Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <cctype>
#include <cstring>
using namespace std;

int main(void) {

  int i , j , n , a , b , as1 , as2 , count;

  string card1 , card2;

  a = b = count = 0;

  cin >> n;

  for(i = 0; i < n ; i++) {

    cin >> card1 >> card2;

    for(j = 0; j < card1.size(); j++) {

      if(isupper(card1[j])) {

	card1[j] = tolower(card1[j]);

      }

    }

    for(j = 0; j < card2.size(); j++) {

      if(isupper(card2[j])) {

	card2[j] = tolower(card2[j]);

      }

    }

    if(card1.size() < card2.size()) {

      for(j = 0; j < card1.size(); j++) {

	as1 = card1[j] - 'a';

	as2 = card2[j] - 'a';

	if(as1 > as2) {

	  a += 3;
	  break;

	} else if(as1 < as2) {

	  b += 3;
	  break;

	} else if(as1 == as2) {

	  count++;

	  continue;

	}

      }

      if(count == card1.size()) {

	if(card1.size() > card2.size()) {

	  a += 3;

	} else if(card1.size() < card2.size()) {

	  b += 3;

	} else if(card1 == card2) {

	a++;
	b++;

	}

      }

    } else {

      for(j = 0; j < card2.size(); j++) {

	as1 = card1[j] - 'a';

	as2 = card2[j] - 'a';

	if(as1 > as2) {

	  a += 3;
	  break;

	} else if(as1 < as2) {

	  b += 3;
	  break;

	} else if(as1 == as2) {

	  count++;

	  continue;

	}

      }

      if(count == card2.size()) {

	if(card1.size() > card2.size()) {

	  a += 3;

	} else if(card1.size() < card2.size()) {

	  b += 3;

	} else if(card1 == card2) {

	  a++;
	  b++;

	}

      }

    }

    count = 0;

  }

  cout << a << " " << b << "\n";

}

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rrep1(i,n) for(int i=n;i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase(unique(all(v)), v.end())
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair

int main() {
	int n;
	cin >> n;
	ll a, b;
	cin >> a >> b;
	vl h(n);
	rep(i, n) {
		cin >> h[i];
	}
	ll ng = 0, ok = inf;
	while (ng + 1 < ok) {
		ll mid = (ng + ok) / 2;
		ll cnt = 0;
		rep(i, n) {
			ll nokori = h[i] - b * mid;
			if (nokori > 0) {
				if (nokori % (a - b) == 0) {
					cnt += nokori / (a - b);
				}
				else {
					cnt += nokori / (a - b) + 1;
				}
			}
		}
		if (cnt > mid) {
			ng = mid;
		}
		else {
			ok = mid;
		}
	}
	cout << ok << endl;
}

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

struct UnionFind{
    vector<int> par;
    UnionFind(int n) : par(n, -1){}
    int root(int x){
        if(par[x]<0) return x;
        else return par[x] = root(par[x]);
    }

    bool same(int a, int b){
        return root(a) == root(b);
    }

    void unite(int a, int b){
        int x = root(a), y = root(b);
        if(x==y) return;
        if(par[y]<par[x]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
    }
};


int main(){
    int n, m;   cin >> n >> m;
    
    vector<int> a(m), b(m);
    for(int i=0; i<m; i++){
        cin >> a.at(i) >> b.at(i);
        a.at(i)--; b.at(i)--;
    }    
    int cnt=0;
    for(int i=0; i<m; i++){
        UnionFind land(n);
        for(int j=0; j<m; j++){
            if(i==j) continue;
            land.unite(a[j], b[j]); 
        }
        if(!land.same(a[i], b[i])) cnt += 1;
    }
    
    cout << cnt << endl;

}

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

namespace _0031
{
    class Program
    {
        static void Main(string[] args)
        {
            int goodsweight = 0;
            Weight weight = new Weight();
            List<int> answerList = new List<int>();
            while (int.TryParse(Console.ReadLine(), out goodsweight))
            {
                 answerList = weight.IsSame(goodsweight);
                
                    Console.WriteLine(string.Join(" ",answerList));
            }
        }
    }
    class Weight
    {
        List<int> weightList = new List<int>() { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512 };
        public List<int> IsSame(int goodsWeight)
        {
            List<int> answerList = new List<int>();
            int i = 0;
            for (int k = 9; k >= 0; k--)
            {
                if (goodsWeight >= weightList[k])
                {
                    i = k;
                    break;
                }
            }
            for (int j = i; j >=0; j--)
            {
                if (weightList[j] <= goodsWeight)
                {
                    goodsWeight -= weightList[j];
                    answerList.Add(weightList[j]);
                }
                if (goodsWeight == 0)
                {
                    break;
                }
            }
            answerList.Reverse();
            return answerList;
        }
    }
}



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

int main(){

	int a, b;
	cin >> a >> b;
	int c;
	if(b < 10) c = 10*a + b;
	else if(b < 100) c = 100*a + b;
	else if(b == 100) c = 1000*a + b;
	for(int i = 4; i <= 350; i++)
	{
		if(c == i * i){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	

	return 0;
}

Measured memory_bytes: 256
n =int(input())

num = list(map(int, input().split()))

box =[0]*n
sum=0
for i in reversed(range (n)):
  sum=0
  for j in (range(int(n/(i+1))-1)):
    sum +=box[i+(i+1)*(j+1)]
  box[i]=(sum+num[i])%2


ans = []
for i in range(n):
  if box[i]==1:
    ans.append(i+1)
print(len(ans))
ans=[str(a) for a in ans]
ans=" ".join(ans)
print(ans)

Measured memory_bytes: 18996
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include<iomanip>
#include<set>
using namespace std ;

#define MAXN 1000007

int n ;
vector < int > v[ MAXN ] ;
int val[ MAXN ] ;

int root ;

pair < int , int > aux[ MAXN ] ;
bool bad = false ;

void init ( int vertex , int prv ) {
    int sz = v[ vertex ].size ( ) ;
    aux[ vertex ] = { - 5 * MAXN , 5 * MAXN } ;
    for ( int i = 0 ; i < sz ; ++ i ) {
        if ( v[ vertex ][ i ] == prv ) { continue ; }
        init ( v[ vertex ][ i ] , vertex ) ;
        aux[ vertex ].first = max ( aux[ vertex ].first , aux[ v[ vertex ][ i ] ].first - 1 ) ;
        aux[ vertex ].second = min ( aux[ vertex ].second , aux[ v[ vertex ][ i ] ].second + 1 ) ;
    }
    if ( val[ vertex ] >= 0 ) {
        aux[ vertex ].first = max ( aux[ vertex ].first , val[ vertex ] ) ;
        aux[ vertex ].second = min ( aux[ vertex ].second , val[ vertex ] ) ;
    }
    if ( aux[ vertex ].first > aux[ vertex ].second ) {
        bad = true ;
    }
}

void dfs ( int vertex , int prv ) {
    int sz = v[ vertex ].size ( ) ;
    for ( int i = 0 ; i < sz ; ++ i ) {
        if ( v[ vertex ][ i ] == prv ) { continue ; }
        if ( val[ v[ vertex ][ i ] ] >= 0 ) {
            if ( abs ( val[ vertex ] - val[ v[ vertex ][ i ] ] ) != 1 ) { bad = true ; }
            dfs ( v[ vertex ][ i ] , vertex ) ;
        }
        else {
            int sr = val[ vertex ] - 1 ;
            if ( aux[ v[ vertex ][ i ] ].first <= sr && sr <= aux[ v[ vertex ][ i ] ].second ) {
                val[ v[ vertex ][ i ] ] = sr ;
                dfs ( v[ vertex ][ i ] , vertex ) ;
            }
            else {
                sr = val[ vertex ] + 1 ;
                if ( aux[ v[ vertex ][ i ] ].first <= sr && sr <= aux[ v[ vertex ][ i ] ].second ) {
                    val[ v[ vertex ][ i ] ] = sr ;
                    dfs ( v[ vertex ][ i ] , vertex ) ;
                }
                else { bad = true ; }
            }
        }
    }
}

void input ( ) {
    scanf ( "%d" , &n ) ;
    for ( int i = 1 ; i <= n ; ++ i ) {
        val[ i ] = -1 ;
    }
    for ( int i = 1 ; i < n ; ++ i ) {
        int x , y ;
        scanf ( "%d%d" , &x , &y ) ;
        v[ x ].push_back ( y ) ;
        v[ y ].push_back ( x ) ;
    }
    int mx = -1 ;
    int k ;
    scanf ( "%d" , &k ) ;
    for ( int i = 1 ; i <= k ; ++ i ) {
        int x , y ;
        scanf ( "%d%d" , &x , &y ) ;
        val[ x ] = y ;
        if ( mx < y ) {
            mx = y ;
            root = x ;
        }
    }
}

void solve ( ) {
    init ( root , -1 ) ;
    dfs ( root , -1 ) ;
    if ( bad == true ) {
        printf ( "No\n" ) ;
        return ;
    }
    printf ( "Yes\n" ) ;
    for ( int i = 1 ; i <= n ; ++ i ) {
        printf ( "%d\n" , val[ i ] ) ;
    }
}


int main ( ) {
    ios_base :: sync_with_stdio ( false ) ;
    cin.tie ( NULL ) ;
    input ( ) ;
    solve ( ) ;
    return 0 ;
}


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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { -1,  0, 1, 0,  1, -1,  1, -1};
static const int dy[8] = {0,  1, 0,  -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;

const int maxn = 1e5+5;
int res = 0;

struct Line{
    LL l,r;
    Line(LL l = 0,LL r = 0):l(l),r(r){;}
    bool operator<(const Line &o){
        return r < o.r;
    }
};

Line lines[maxn];

int main()
{
    int N;
    cin >> N;
    _for(i,0,N){
        LL a,r;
        cin >> a >> r;
        lines[i] = Line(a-r,a+r);
    }

    sort(lines,lines+N);

    int befr = lines[0].r;
    res = 1;
    _for(i,1,N){
        if(lines[i].l >= befr){
            res++;
            befr = lines[i].r;
        }
    }

    cout << res <<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>
#include <tuple>
#include <sstream>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;
const int INF = 1e9;

int main(int argc, const char * argv[]) {
    //    ifstream in("input.txt");
    //    cin.rdbuf(in.rdbuf());
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, T;
    cin >> n >> T;
    
    vector<int> c(n), t(n);
    int min_c = INF;
    rep(i, n)
    {
        cin >> c[i] >> t[i];
        if (t[i] <= T)
        {
            min_c = min(min_c, c[i]);
        }
    }
    if (min_c == INF) cout << "TLE" << endl;
    else cout << min_c << endl;
    
    
    
    
    return 0;
}

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

#define ff first
#define ss second
#define PI acos(-1)
#define pb push_back
#define int long long
#define ld long double
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int M = (1e9)+7;
const int N = 1e7+5;

int spf[N],ans[N];
void sieve()
{
    ans[1] = 1;
    for(int i=2;i<N;i++)
    {
        if(!spf[i])
        {
            spf[i]=i;
            for(int j=i*i;j<N;j+=i)if(!spf[j])spf[j]=i;
        }
        int n = i,p = spf[n],c = 0;
        while(!(n%p))n/=p,c++;
        ans[i] = ans[n]*(c+1);
    }
    for(int i=2;i<N;i++)ans[i]*=i;
    for(int i=2;i<N;i++)ans[i]+=ans[i-1];
}

signed main()
{
    FAST
    int tc=1;
    sieve();
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        int n;
        cin>>n;
        cout<<ans[n]<<endl;
    }
    return 0;
}


Measured memory_bytes: 159896
import java.io.BufferedReader;
import java.io.InputStreamReader;
 
class Main{
    static double before[][];
    static double after[][];
    static boolean souko[][];
    public static void main(String args[]){
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try{
            while(true){
                int n = Integer.parseInt(br.readLine());
                if(n == 0) return;
 
                String strs[] = br.readLine().split(" ");
                char s = strs[0].charAt(0);
                char t = strs[1].charAt(0);
                char b = strs[2].charAt(0);
 
                before = new double[3][3];
                souko = new boolean[3][3];
 
                int bs[] = charToInts(b);
                souko[bs[0]][bs[1]] = true;
 
                int ss[] = charToInts(s);
                before[ss[0]][ss[1]] = 1.0;
 
                for(int i = 0; i < n; i++){
                    after = new double[3][3];
                    calc();
                    before = after;
                }
 
                int ts[] = charToInts(t);
                System.out.println(before[ts[0]][ts[1]]);
            }
        }catch(Exception e){
        }
    }
 
    static void calc(){
        for(int i = 0; i < 3; i++){
            for(int j = 0; j < 3; j++){
                double p = before[i][j] * 0.25;
                // ←
                if(j == 0 || souko[i][j-1]){
                    after[i][j] += p;
                }else{
                    after[i][j-1] += p;
                }
 
                // ↑
                if(i == 0 || souko[i-1][j]){
                    after[i][j] += p;
                }else{
                    after[i-1][j] += p;
                }
 
                // →
                if(j == 2 || souko[i][j+1]){
                    after[i][j] += p;
                }else{
                    after[i][j+1] += p;
                }
 
                // ↓
                if(i == 2 || souko[i+1][j]){
                    after[i][j] += p;
                }else{
                    after[i+1][j] += p;
                }
            }
        }
    }
 
    static int[] charToInts(char c){
        int m = c - 'A';
        int result[] = {m / 3, m % 3};
        return result;
    }
}

Measured memory_bytes: 17124
#include <stdio.h>
int fuction(int a,int b)
{
  int c=1;
  while(c!=0){
    c=a%b;
    a=b;
    b=c;
  }
  return a;
}
int main()
{
  int n;
  int i,j,k;
  int sum=0;
   scanf("%d",&n);
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      for(k=1;k<=n;k++){
            sum=sum+fuction(fuction(i,j),k);
      }
    }
  }
  printf("%d",sum);
  return 0;
}

Measured memory_bytes: 1704
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const long long MOD = 1000000007;

vector<int> places[210000];
long long dp[210000];
void add(long long &a, long long b){
	a += b;
	if(a >= MOD)a -= MOD;
}

int main(){
	//入力
	int N;
	cin >> N;
	vector<int> c(N);
	for(int i = 0;i < N;++i)cin >> c[i];

	//places[i] := (c[j] = iとなるようなjの集まり(各色ごとにvectorをもつ.))
	for(int i = 0;i < 210000; ++i){
		places[i].clear();
	}
	for(int i = 0;i < N;i++){
		places[c[i]].push_back(i);
	}

	//DP
	dp[0] = 1;
	for (int i = 1;i <= N;i++){
		//今見ている場所に仕切りを挿入しない場合(手前とペアを作らない場合)
		add(dp[i],dp[i-1]);

		//操作する場合
		int color = c[i-1];
		
		//c[i]がcolorの何番目の要素か
		int it = lower_bound(places[color].begin(),places[color].end(),i-1) - places[color].begin();

		if(it > 0){
			int j = places[color][it-1];//c[j]=c[i]となるj
			if((i-1) - j > 1)add(dp[i],dp[j+1]);
		}
	}

	cout << dp[N] << endl;
}


Measured memory_bytes: 13824
#include <string>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <math.h>

#define MOD 1000000007

using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
 
	int x;
	cin >> x;
    cout << x+x*x+x*x*x;
  
}

Measured memory_bytes: 3640
#[allow(unused_imports)]
use proconio::{input, marker::*};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

fn main() {
    input! {
        n: usize,
        k: usize,
        a: [Usize1;n],
    }

    let mut vec = vec![vec![0; 64]; n];
    for i in 0..n {
        vec[i][0] = a[i];
    }

    for j in 1..64 {
        for i in 0..n {
            vec[i][j] = vec[vec[i][j - 1]][j - 1];
        }
    }

    let mut current = 0;
    for i in 0..64 {
        if (k >> i) & 1 == 1 {
            current = vec[current][i];
        }
    }
    println!("{}", current + 1);
}


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

const int N = 200;
char a[N][N];
int dp[2][N][N][N], n, m, limit;

void up(int &x, int y) { x = std::max(x, y); }
int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n >> m;
	for (int i = 1; i <= n; ++i) std::cin >> a[i] + 1;
	limit = 65 - __builtin_clz(n) - __builtin_clz(m);
	int now = 0, lst = 1;
	for (int r = n; r >= 1; --r)
		for (int c1 = 1; c1 <= m; ++c1)
			for (int c2 = c1; c2 <= m && a[r][c2] == a[r][c1]; ++c2)
				dp[now][r][c1][c2] = 1 + (a[r][c1] == a[r + 1][c1] ? dp[now][r + 1][c1][c2] : 0);
	for (int time = 1; time <= limit; ++time) {
		if (dp[now][1][1][m] == n)
			return std::cout << time - 1 << '\n', 0;
		std::swap(now, lst);
		for (int r = 1; r <= n; ++r)
			for (int c1 = 1; c1 <= m; ++c1)
				for (int c2 = c1; c2 <= m; ++c2) {
					dp[now][r][c1][c2] = dp[lst][r][c1][c2] + dp[lst][r + dp[lst][r][c1][c2]][c1][c2];
					auto calc = [&] (int mid) {
						up(dp[now][r][c1][c2], std::min(dp[lst][r][c1][mid], dp[lst][r][mid + 1][c2]));
						return dp[lst][r][c1][mid] > dp[lst][r][mid + 1][c2];
					};
					int L = c1, R = c2 - 1;
					while (L <= R) {
						int mid = L + R >> 1;
						if (calc(mid)) L = mid + 1; else R = mid - 1;
					}
				}
	}
	std::cout << "-1" << std::endl;
	return 0;
}

Measured memory_bytes: 61440
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)

int main(void){
  string s,p;
  int n;
  while(cin>>n,n){
    int ret = 0;
    cin>>p;
    rep(i,n-1){
      cin>>s;
      if(s[0] != p[0] && s[1] == p[1])ret++;
      p=s;
    }
    cout<<ret<<endl;
  }

}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=20000005,INF=1<<30;

ll inv[MAX],fac[MAX],finv[MAX];

void make(){
    
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    
    for(int i=2;i<MAX;i++){
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        fac[i]=fac[i-1]*(ll)i%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
    
}

ll comb(ll a,ll b){
    if(a<b) return 0;
    return fac[a]*(finv[b]*finv[a-b]%mod)%mod;
}

ll perm(ll a,ll b){
    if(a<b) return 0;
    return fac[a]*finv[a-b]%mod;
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    make();
    
    ll H,W,K;cin>>H>>W>>K;
    
    ll ans=0;
    
    ans+=perm(H+W,K)*K%mod;
    
    for(int t=1;t<=K;t++){
        ans+=(H+W)*perm(H+W-1,K-1)%mod*(K+1-t)%mod;
        ans%=mod;
    }
    
    for(int t=2;t<=K;t++){
        ans+=(H*W*2)%mod*(t-1)%mod*perm(H+W-2,K-2)%mod*(K+1-t)%mod;
        ans%=mod;
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 469120
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int main() {
  int h,w;
  cin>>h>>w;
  vector<string> s(h);
  rep(i,h) cin>>s[i];
  int ans=0;
  rep(si,h)rep(sj,w){
    if(s[si][sj]=='#') continue;
    vector<vector<int>> dist(h,vector<int>(w,INF));
    queue<P> q;
    auto update=[&](int i,int j,int x){
      if(dist[i][j]!=INF) return;
      dist[i][j]=x;
      q.push(P(i,j));
    };
    update(si,sj,0);
    while(!q.empty()){
      int i=q.front().first;
      int j=q.front().second; q.pop();
      rep(dir,4){
        int ni=i+di[dir], nj=j+dj[dir];
        if(ni<0||ni>=h||nj<0||nj>=w) continue;
        if(s[ni][nj]=='#') continue;
        update(ni,nj,dist[i][j]+1);
      }
    }
    rep(i,h)rep(j,w){
      if(dist[i][j]==INF) continue;
      ans=max(ans,dist[i][j]);
    }
  }
  cout<<ans<<endl;
}

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

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

    int count = 0;

    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        int h;
        cin >> h;
        if (h >= k)
            count++;
    }

    cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cassert>
#include <string>
#include <map>
#include <algorithm>
#include <queue>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;

int main() {
	int k;  cin >> k;
	queue<string> q;
	q.push("1");
	q.push("2");
	q.push("3");
	q.push("4");
	q.push("5");
	q.push("6");
	q.push("7");
	q.push("8");
	q.push("9");
		int cnt = 0;
	while (true) {
		auto s = q.front();
		q.pop();
		cnt++;
		if (cnt == k) {
			cout << s << endl;
			return 0;

		}
		int last = s[s.size() - 1] - '0';
		if (0 < last)
			q.push(s + char(last - 1 + '0'));
		q.push(s + char(last + '0'));
		if (last < 9) 
			q.push(s + char(last + 1 + '0'));
		
	}
	return 0;
}

Measured memory_bytes: 9676
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <string>
#include <string.h>
#include <math.h>
#include <iomanip>
#include <stdio.h>
using namespace std;

#define int64 long long
#define pii pair <int64, int64>
#define fr first
#define sc second
#define heap priority_queue
struct piii{
    int64 fr, sc, th;
    bool operator < (const piii &b){
        if (fr != b.fr) return fr < b.fr;
        if (sc != b.sc) return sc < b.sc;
        return th < b.th;
    }
};
///////////////////////////////////////////////
///////////////////////////////////////////////

string s, t;

int main(){
    cout << setprecision(2) << fixed;
    ios::sync_with_stdio(false), cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    cin >> s >> t;
    for (int i = 0; i < s.size(); i++) cout << s[i] << t[i];
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <set>
#define N 500007
#define IL inline
#define REP(a,b,c) for(a=b;a<=c;a++)
#define PER(a,b,c) for(a=b;a>=c;a--)
using namespace std;
set<int> S;
set<int>::iterator it;
int n,k,P[N],Q[N];
int head[N],lt[N<<1],nt[N<<1],ap=1,d[N];
int a[N],len;
IL int rd(){
	int res=0;char c;while((c=getchar())<'0'||c>'9');
	while(c>='0'&&c<='9')res=res*10+c-'0',c=getchar();return res;
}
IL void link(int a,int b){
	lt[++ap]=b,nt[ap]=head[a],head[a]=ap,d[b]++;
}
IL void up(int i){
	int j=i>>1,x=a[i];
	while(j && x<a[j])a[i]=a[j],i=j,j>>=1;
	a[i]=x;
}
IL void down(int i){
	int j=i<<1,x=a[i];
	while(j<=len){
		if(j<len && a[j+1]<a[j])j++;
		if(a[j]<x)a[i]=a[j],i=j,j<<=1;else break;
	}
	a[i]=x;
}
IL void push(int b){a[++len]=b;up(len);}
IL int pop(){int b=a[1];a[1]=a[len--];down(1);return b;}
int main(){
	int i,u,x;
	n=rd(),k=rd();REP(i,1,n)Q[P[i]=rd()]=i;
	REP(i,1,n){
		if(i>k)S.erase(P[i-k]);it=S.insert(P[i]).first;
		if(++it!=S.end())link(i,Q[*it]);
	}
  S.clear();
	PER(i,n,1){
		if(i+k<=n)S.erase(P[i+k]);it=S.insert(P[i]).first;
		if(++it!=S.end())link(i,Q[*it]);
	}
	REP(i,1,n)if(!d[i])push(i);
	REP(i,1,n)
		for(u=pop(),x=head[u],P[u]=i;x;x=nt[x])
			if(!--d[lt[x]])push(lt[x]);
	REP(i,1,n)printf("%d\n",P[i]);
  return 0;
}

Measured memory_bytes: 42624
inf = 10**9
n = int(input())
h = [int(i) for i in input().split()]
dp = [inf for i in range(n+10)]

def chmin(a,b):
    if (a>b):
        return b
    else:
        return a
      
dp[0] = 0
for i in range(1,n):
    dp[i] = chmin(dp[i],dp[i-1]+abs(h[i]-h[i-1]))
    if i>1:
      dp[i] = chmin(dp[i],dp[i-2]+abs(h[i]-h[i-2]))
print(dp[n-1])

Measured memory_bytes: 20472
n = gets.to_i
arr = gets.chomp.split.map(&:to_i)
puts arr.join(" ")

1.upto(n - 1){|i|
    value = arr[i]
    j = i
    while j > 0 && arr[j - 1] > value
        arr[j] = arr[j - 1]
        j -= 1
    end
    arr[j] = value
    puts arr.join(" ")
}

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

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

    int dp[N];
    int a[N];
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
        dp[i] = LLONG_MAX;
        //cout << a[i] << "\n";
    }
    dp[0] = 0;
    for (int i = 1; i < N; i++)
    {
        for (int j = i - 1; j >= i - K && j>=0; j--)
        {
            dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
        }
    }
    /* cout << "\n";
    for (int i = 0; i < N; i++)
    {
        cout << dp[i] << "\n";
    } */
    cout << dp[N - 1];
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s,a;
	cin>>s;
	int l = s.length();
	for(int i = 1;i<=l;i++){
		if(i%2 == 1){
			a+=s[i-1];
		}
	}
	cout<<a<<"\n";
	return 0;
}

Measured memory_bytes: 512
t,l,b,a,I,J,s;main(n){while(scanf("%d%d%d%d",&n,&t,&l,&b),n){float d[101][101]={{}},o=0;int f[101]={};while(b+l--)scanf("%d",&a),f[a]=(l>=0)+1;d[0][0]=1;for(l=0;l<=t;l++){o+=d[l][n];d[l][n]=0;for(b=0;b<=n;b++){I=l+(f[b]-2?1:2);if(I<=t)for(s=1;s<7;s++){J=b+s;if(J>n)J=2*n-J;J=f[J]-1?J:0;d[I][J]+=d[l][b]/6;}}}printf("%f\n",o);}}

Measured memory_bytes: 1780
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    int sum = 0;
    for (int i = 0; i < N; i++) {
        int l, r;
        cin >> l >> r;
        sum += r - l + 1;
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
int n;
#include <cassert>
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

map<int, int> prime_factor(int n) {
  map<int, int> res;
  for(int i=2; i*i<=n; i++) {
    while(n % i == 0) {
      ++res[i];
      n /= i;
    }
  }
  if(n != 1) ++res[n];
  return res;
}

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

  cin >> n;
  vector<ll> a(n);
  map<int, int> mp;

  REP(i, n) {
    cin >> a[i];
    auto tmp = prime_factor(a[i]);
    for(auto u : tmp) {
      mp[u.first] = max(mp[u.first], u.second);
    }
  }

  mint t = 1;
  for(auto u : mp) {
    REP(i, u.second) {
      t *= u.first;
    }
  }

  mint ans = 0;
  REP(i, n) {
    ans += t / a[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 4096
#include<iostream>
#include<cstdio>
using namespace std;
int n,m,i,j,k,a[3010];
long long ans;
int main(){
	scanf("%d",&n);for (i=1;i<=n;i++) scanf("%d",&a[i]),ans+=a[i];printf("%lld\n",ans-n);return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

void func(){

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

	int table[N];
	for(int i = 0; i < N; i++)scanf("%d",&table[i]);

	int dp[N][N];

	for(int i = 0; i < N; i++){
		for(int k = 0; k < N; k++){
			dp[i][k] = 0;
		}
	}

	for(int length = 1; length <= N-1; length++){
		for(int i = 0; i < N; i++){
			for(int k = 0; k < length; k++){
				dp[i][length] = max(dp[i][length],dp[i][k]+dp[(i+k+1)%N][length-k-1]+abs(table[i]-table[(i+k+1)%N]));
			}
		}
	}

	int ans = 0;
	for(int i = 0; i < N; i++){
		ans = max(ans,dp[i][N-1]);
	}

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

}

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

	for(int i = 0; i < num_case; i++)func();

	return 0;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, x, n) for (ll i = x; i < (ll)(n); i++)
#define lb lower_bound
#define ub upper_bound
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};

signed main()
{
    db a,b,c,x1,x2,x3,y1,y2,y3,mx,r,s;
    cin>>x1>>y1>>x2>>y2>>x3>>y3;

    a=sqrt(pow(x2-x1,2)+pow(y2-y1,2));
    b=sqrt(pow(x2-x3,2)+pow(y2-y3,2));
    c=sqrt(pow(x3-x1,2)+pow(y3-y1,2));

    mx=max({a,b,c});
    
    s=(a+b+c)/2;

    r=sqrt((s-a)*(s-b)*(s-c))/sqrt(s);

    cout<<fixed<<setprecision(20)<<mx*r/(2*r+mx)<<endl;

}


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

#define PI 3.14159265358979


void solve(long long A, long long B, long long H, long long M){
    double m = 2 * PI * ((double)M / 60);
    double h = 2 * PI * ((double)(H * 60 + M) / 720);
    double ax = A * sin(h);
    double ay = A * cos(h);
    double bx = B * sin(m);
    double by = B * cos(m);
    printf("%.10lf\n", sqrt((ax-bx)*(ax-bx) + (ay-by)*(ay-by)));
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long H;
    scanf("%lld",&H);
    long long M;
    scanf("%lld",&M);
    solve(A, B, H, M);
    return 0;
}


Measured memory_bytes: 4192
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func main() {
    let nm = readInts()
    let (n, m) = (nm[0], nm[1])
    ///展望台の標高
    let aryElevation = readInts()
    var aryAns = [Bool](repeating: true, count: n)
    for _ in 0..<m {
        let ab = readInts()
        let (a, b) = (ab[0], ab[1])
        if aryElevation[a-1] <= aryElevation[b-1] {
            aryAns[a-1] = false
        }
        if aryElevation[b-1] <= aryElevation[a-1] {
            aryAns[b-1] = false
        }
        
    }
    print(aryAns.filter { $0 == true}.count)
}
main()


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 1e9+7;


int main(){
	//ios_base::sync_with_stdio(false);
	int N, ans=0;
	int a[100005], cnt[100005]={};

	cin >> N;
	rep(i,N) cin >> a[i];

	rep(i,N) rep(k,3){
		chmax(ans, ++cnt[ a[i]+k ]);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n,d[305][305];
long long ans;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)scanf("%d",&d[i][j]);
	for(int i=1;i<=n;i++)for(int j=i+1;j<=n;j++)
	{
		bool f=0;
		for(int k=1;k<=n;k++)
		{
			if(i==k||j==k)continue;
			f|=d[i][j]==d[i][k]+d[j][k];
			if(d[i][k]+d[j][k]<d[i][j])
			{
				puts("-1");
				return 0;
			}
		}
		if(!f)ans+=d[i][j];
	}
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 640
# see: https://kimiyuki.net/blog/2016/06/27/icpc-2016-domestic-c/

loop do
  m, n = gets.split.map(&:to_i)
  break if m == 0

  nxt = m
  used = []
  n.times do |i|
    a = nxt
    while a <= 7368791
      used[a] = true
      a += nxt
    end

    loop do
      nxt += 1
      break unless used[nxt]
    end
  end

  puts nxt
end

Measured memory_bytes: 239004
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let c: i64 = input();
    let stc: Vec<(i64, i64, i64)> = (0..n)
        .map(|_| {
            let s = input();
            let t = input();
            let c = input();
            (s, t, c)
        })
        .collect();

    let mut sum = vec![0; 200010];
    for ch in 1..c + 1 {
        let mut v = vec![0; 200010];
        for i in 0..n {
            let (s, t, c) = stc[i];
            if ch == c {
                for j in 2 * s - 1..2 * t + 1 {
                    v[j as usize] = 1;
                }
            }
        }
        for i in 0..200010 {
            sum[i] += v[i];
        }
    }

    println!("{}", sum.iter().max().unwrap());
}


Measured memory_bytes: 10492
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;
const ll MINF = LLONG_MIN;
const int INT_INF = INT_MAX;

int main()
{
    ll a, b, v, w, t;
    cin >> a >> v >> b >> w >> t;
    ll ax, bx;
    ax = v * t;
    bx = w * t;
    ll x, y;
    if (a > b)
    {
        x = a - ax;
        y = b - bx;
        cout << (x <= y ? "YES" : "NO") << endl;
    }
    else
    {
        x = a + ax;
        y = b + bx;
        cout << (x >= y ? "YES" : "NO") << endl;
    }
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    string s;
    cin >> s;
    int x, y;
    cin >> x >> y;

    // ランレングス圧縮
    int n = sz(s);
    vector<pair<char, int>> cnt;
    cnt.emplace_back(s[0], 0);
    rep(i, n) {
        if (cnt.back().fi == s[i]) cnt.back().se++;
        else cnt.emplace_back(s[i], 1);
    }

    // 移動をx成分とy成分に分ける（初めのFは別で処理）
    int sx = 0, sy = 0;
    vector<int> xlist, ylist;
    int now = 0;
    rep(i, sz(cnt)) {
        if (i == 0 && cnt[i].fi == 'F') {
            sx += cnt[i].se;
        } else if (cnt[i].fi == 'T') {
            now ^= (cnt[i].se % 2);
        } else {
            if (now == 0) xlist.push_back(cnt[i].se);
            else ylist.push_back(cnt[i].se);
        }
    }

    // どこに移動できるかDP（10000を0としている）
    vector<bool> to_x(32000, false);
    vector<bool> to_y(32000, false);
    to_x[16000] = true;
    to_y[16000] = true;

    rep(i, sz(xlist)) {
        vector<bool> pre_x(32000, false);
        swap(to_x, pre_x);
        rep(j, 32000) if (pre_x[j]) {
            to_x[j + xlist[i]] = true;
            to_x[j - xlist[i]] = true;
        }
    }

    rep(i, sz(ylist)) {
        vector<bool> pre_y(32000, false);
        swap(to_y, pre_y);
        rep(j, 32000) if (pre_y[j]) {
            to_y[j + ylist[i]] = true;
            to_y[j - ylist[i]] = true;
        }        
    }

    // 移動できるかチェック
    int dx = x - sx, dy = y - sy;
    dx += 16000, dy += 16000;
    if (to_x[dx] && to_y[dy]) puts("Yes");
    else puts("No");
}


Measured memory_bytes: 3716
//package atcoder.beginner_174;

import java.io.*;
import java.util.StringTokenizer;

public class Main {

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

        String s = "20 100000\n" +
                "14309 -32939\n" +
                "-56855 100340\n" +
                "151364 25430\n" +
                "103789 -113141\n" +
                "147404 -136977\n" +
                "-37006 -30929\n" +
                "188810 -49557\n" +
                "13419 70401\n" +
                "-88280 165170\n" +
                "-196399 137941\n" +
                "-176527 -61904\n" +
                "46659 115261\n" +
                "-153551 114185\n" +
                "98784 -6820\n" +
                "94111 -86268\n" +
                "-30401 61477\n" +
                "-55056 7872\n" +
                "5901 -163796\n" +
                "138819 -185986\n" +
                "-69848 -96669";

//        br = new BufferedReader(new StringReader(s));
        br = new BufferedReader(new InputStreamReader(System.in));
        bw = new BufferedWriter(new OutputStreamWriter(System.out));

        rl(); int n=nin(), d=nin();
        int c=0;
        for (int i=0; i<n; ++i) {
            rl();
            double x=ndo(), y=ndo();
            double D=Math.sqrt(x*x+y*y);
            if (D<=d) ++c;
        }

        bw.write(Integer.toString(c));
        bw.newLine();
        bw.flush();

    }

    static BufferedReader br;
    static BufferedWriter bw;
    static StringTokenizer st;
    static void rl() throws Exception{
        st = new StringTokenizer(br.readLine());
    }
    static long nlo(){
        return Long.parseLong(st.nextToken());
    }
    static int nin(){
        return Integer.parseInt(st.nextToken());
    }
    /*private static void te(){
      }*/
    static double ndo(){
        return Double.parseDouble(st.nextToken());
    }
    static char[] nca(){
        return st.nextToken().toCharArray();
    }
    static String nstr(){
        return st.nextToken();
    }
}

Measured memory_bytes: 55660
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
    using namespace std;
 
    int main(){
      ll n,m;
      cin >> n >> m;
      ll ans=0;
      ll x=m/n;
      if(m%n==0) cout << x << endl;
     else{
      for(ll i=1;i<=sqrt(m)+1;i++){
        ll y=m/i;
       if(m%i==0 && i<=x){
         ans=max(ans,i);
       }
       if(m%y==0 && y<=x){
        ans=max(ans,y); 
       }
      }
      cout << ans << endl;
     }
      return 0;}

Measured memory_bytes: 256