akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long ;
int i_max(int arr[],int n){
    int MAX=arr[0];
   int  i1=0,i2=0;
    for (int i= 0;i<n;i++)
    {
        if (arr[i]>MAX)
        {
            MAX =arr[i];
            i1=i;
            i2=i;
        }
        else if (arr[i]==MAX)
        {
            i2=i;
        }
   }
    return max(i1,i2);
}
int i_min(long long int arr[],int n,int& i1,int& i2){
    long long int min=arr[0];
    i1=0;
    i2=0;
     for (int i= 0;i<n;i++)
     {
         if (arr[i]<min)
         {
             min =arr[i];
             i1=i;
             i2=i;
         }
         else if (arr[i]==min)
         {
             i2=i;
         }
    }
     return max(i1,i2);
}

ll gcd(ll a,ll b){
    if (b==0)
        return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a/g*b;
}
int main (){
    // two magical lines to speed up IO
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    ll ans =1;
    for (int i=0;i<n;i++){
        ll t;
        cin >>t;
        ans = lcm(ans,t);
        
    }
    cout << ans<<"\n";
}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    double A, B, H, M;
    cin >> A >> B >> H >> M;
    double angleH = (360.0 / 12) * H + (360.0 / (12 * 60)) * M;
    double angleM = (360.0 / 60) * M;
    double diff = abs(angleH - angleM);
    double diffR = (diff / 360.0) * 2 * M_PI;
    double ans = sqrt(A * A + B * B - 2 * A * B * cos(diffR));

    cout << fixed;
    cout << setprecision(10) << ans << endl;
}


Measured memory_bytes: 4256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <utility>
#include <functional>
#include <tuple>

using namespace std;

#define rep(i,x) for(int i=0;i<x;++i)
#define fst first
#define scd second

using pii=pair<int,int>;
using vpii=vector<pii>;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;

using data=tuple<int, int, int>;

struct edge{
    int to, cost, id;
};

int edge[105][105];
int d[105][105];
int E[1005];

signed main()
{
    int N, M; cin >> N >> M;

    fill_n(E, M + 1, -1);
    rep(i, N) rep(j, N) d[i][j] = i == j ? 0 : 1e9;

    rep(i, M) {
        int a, b, c; cin >> a >> b >> c;
        --a, --b;

        E[i+1] = c;
        d[a][b] = d[b][a] = c;

        edge[a][b] = edge[b][a] = i+1;
    }

    rep(k, N) rep(i, N) rep(j, N) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    }

    int cnt = 0;

    rep(i, N) rep(j, i) {
        if (edge[i][j]) {
            if (E[edge[i][j]] == d[i][j]) cnt++;
        }
    }

    cout << M - cnt << endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<sstream>
using namespace std;

int main(){
	int n;
	string str;
	while(cin >> n && n){
		cin >> str;
		while(n--){
			int len = str.size();
			int cou = 1;
			string next = "";
			for(int i=0;i<len;i++){
				if(str[i] == str[i+1]) cou++;
				else {
					string tmp = "";
					stringstream s;
					s << cou;
					next += s.str();
					next += str[i];
					cou = 1;
				}
			}
			if(cou!=1){
				string tmp = "";
				stringstream s;
				s << cou;
				next += s.str();
				next += str[len-1];
				cou = 1;
			}
			str = next;
		}
		cout << str << endl;
	}
}

Measured memory_bytes: 1364
import java.util.Scanner;

/**
 * コンソールテスト用Main クラス
 *
 * @author RisaTozawa
 */
public class Main {

	/* コンストラクタ */
	Main() {
	//何もしない
	}

	/**
	 * Atcorder 提出
	 * @return
	 *
	 */

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

		int goukei = 0;

		/* 人数分だけ個数の合計を求める */
		for (int i = 1; i <= ninnzuu; i++) {

			goukei = goukei + i;
		}

		/* 合計をコンソールに表示する */
		System.out.println(goukei);

	}

}


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

int main() {
	int n;
	while(1){
		cin >> n;
		if(n == 0) break;
		int a[10000], b[10000], A=0, B=0;
		for(int i=0; i<n; i++){
			cin >> a[i] >> b[i];
			int sum = a[i]+b[i];
			if(a[i]>b[i]) A += sum;
			if(a[i]==b[i]){
				A += a[i];
				B += b[i];
			}
			if(a[i]<b[i]) B += sum;
		}
		cout << A << ' ' << B << endl;
	}
	return 0;
}


Measured memory_bytes: 3164
#include<stdio.h>
 
long max(long a,long b){
	if(a>b){
    	return a;
    }else{
    	return b;
    }
}
 
long min(long a,long b){
	if(a<b){
    	return a;
    }else{
    	return b;
    }
}
 
int f(long a,long b){
  long c=max(a,b);
  int keta=1;
  for(int i=0;i<10;i++){
  	if(c/10>0){
    	keta++;
      	c/=10;
    }
  }
  return keta;
}
 
 
 
int main(void){
  
  long N;
  int minnum=11;
  scanf("%ld",&N);
  
  for(long a=1;a*a<=N;a++){
    long b=0;
  	if(N%a == 0){
      b=N/a;
      b=f(a,b);
      minnum=min(minnum,b);
    }
  }
  
  printf("%ld",minnum);
  
 
return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<fstream>
#include<algorithm>
#include<string>
using namespace std;
string st;
int k;
int main()
{
     cin>>st;
     for(int i=0;i<=st.size();i++) 
     {
     	if(st[i]=='C')k=1;
     	if(k==1&&st[i]=='F')
		{
		 	cout<<"Yes";
		 	return 0;
		}
     }
     cout<<"No";
    return 0;
}

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

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define vi vector<int>

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cerr << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define debug(...) CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) (__VA_ARGS__)

using namespace std;
using ll = long long;
using P = pair<int, int>;

// Sieve of Eratosthenes
struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n) : n(n), f(n + 1) {
    f[0] = f[1] = -1;
    for (int i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.emplace_back(i);
      f[i] = i;
      for (int j = i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }

  bool isPrime(int x) { return f[x] == x; }

  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }

  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p)
        res.back().second++;
      else
        res.emplace_back(p, 1);
    }
    return res;
  }
} primes(100);

int comb(int n, int r) {
  if (n < r) return 0;
  int x = 1;
  rep(i, r) x = x * (n-i) / (i+1);
  return x;
}

void Main() {
  int n;
  cin >> n;
  map<int, int> m;
  REP(i, 2, n+1) for (int a : primes.factorList(i)) m[a]++;
  int t = 0;
  int f = 0;
  auto num = [&](int n) {
    int count = 0;
    for (auto itr=m.begin(); itr!=m.end(); ++itr) {
      if (itr->second>=n-1) count++;
    }
    return count++;
  };
  int ans = 0;
  ans += num(5) * (num(5) - 1) * (num(3) - 2) / 2;
  ans += num(15) * (num(5) - 1);
  ans += num(25) * (num(3) - 1);
  ans += num(75);
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    string a;

    cin>>a;
    if(a=="Sunny")
    {cout<<"Cloudy";}
    else if(a=="Cloudy")
    {cout<<"Rainy";}
    else if (a=="Rainy")
    {
        cout<<"Sunny";
    }
    

    return 0;
}


Measured memory_bytes: 256
import networkx as nx

H,W = map(int,input().split())
a = [input() for _ in range(H)]
INF = 10**20

G = nx.Graph()
G.add_nodes_from(range(0,H+W+2))
for i in range(H):
  for j in range(W):
    if a[i][j]=='o':
      G.add_edge(i+1,j+H+1,capacity=1)
    if a[i][j]=='S':
      G.add_edge(0,i+1,capacity=INF)
      G.add_edge(0,j+H+1,capacity=INF)
    if a[i][j]=='T':
      G.add_edge(H+W+1,i+1,capacity=INF)
      G.add_edge(H+W+1,j+H+1,capacity=INF)
      
flow_value,flow_dict = nx.maximum_flow(G,0,H+W+1)
print(flow_value if flow_value < INF else -1)

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

int main() {
	int n, k, q;
	cin >> n >> k >> q;
	int arr[n];
	
	for (int i = 0 ;i < n ;i++)
		arr[i] = k - q;
	for (int i = 0; i < q; i++) {
		int x;
		cin >> x;
		arr[x - 1]++;
	}
	for (int i = 0; i < n; i++) {
		if (arr[i] > 0)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}

}


Measured memory_bytes: 1024
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(int argc, char const *argv[]) {
    string S;
    cin >> S;
    size_t size = S.length();
    int len=0;
    if(size%2==1){
        len = size/2 + 1;
    }else{
        len = size/2;
    }
    bool kan = true;
    bool ni = true;

    FOR(i,0,len){
        if(S[(2*i)]=='L'){
            kan = false;
            break;
        }
    }
    FOR(i,0,len){
        if(S[(2*i)+1]=='R'){
            ni = false;
            break;
        }
    }



    if(kan && ni){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc138/tasks/abc138_d

#include <bits/stdc++.h>
using namespace std;
// #define cerr if(false) cerr
#define watch(x) cerr << (#x) << " is " << (x) << endl;
#define endl '\n'
#define ld long double
#define int long long
#define pii pair<int, int>
#define fi first
#define se second
#define sz(a) (int)a.size()
#define all(x) (x).begin(), (x).end()

void solve() {
    
}

const int maxn = 200500;

vector<int> G[maxn];
bool vis[maxn];
int sum[maxn];

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

    int N, Q;
    cin >> N >> Q;

    for(int i = 1; i <= N-1; i++) {
        int u, v;
        cin >> u >> v;

        G[u].emplace_back(v);
        G[v].emplace_back(u);
    }

    while(Q--) {
        int p, x;
        cin >> p >> x;

        sum[p] += x;
    }

    queue<int> Qu;
    Qu.push(1);
    vis[1] = true;

    while(!Qu.empty()) {
        int S = Qu.front(); Qu.pop();

        for(int adj: G[S]) {
            if(!vis[adj]) {
                Qu.push(adj);
                vis[adj] = true;
                
                sum[adj] += sum[S];
            }
        }
    }

    for(int i = 1; i <= N; i++) {
        cout << sum[i] << " ";
    }
    cout << endl;
}

/*

*/

// Did you read the bounds?
// Did you make typos?
// Are there edge cases (N=1?)
// Are array sizes proper (scaled by proper constant, for example 2* for koosaga tree)
// Integer overflow?
// DS reset properly between test cases?
// Is using long longs causing TLE?
// Are you using floating points?


Measured memory_bytes: 19180
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	int ans=0;
	cin >>n;
	cout<<n*n+n+n*n*n<<endl;
}

Measured memory_bytes: 3588
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  ll H,W,ans=100000000;
  cin>>H>>W;
  if(H%3==0 || W%3==0) ans=0;
  else{
    ll t,a,b,c;
    FFOR(i,1,H-1){
      a=i*W;
      b=(H-i)*(W/2);
      c=(H-i)*(W-W/2);
      t=max(a,max(b,c))-min(a,min(b,c));
      ans=min(ans,t);
    }
    ll Q=H;
    H=W;
    W=Q;
    FFOR(i,1,H-1){
      a=i*W;
      b=(H-i)*(W/2);
      c=(H-i)*(W-W/2);
      t=max(a,max(b,c))-min(a,min(b,c));
      ans=min(ans,t);
    }
  }
  cout<<min(ans,min(H,W))<<endl;
}


Measured memory_bytes: 768
# 種類が同じ寿司であれば、最も美味しさが高い寿司を選ぶべき。
# 従い、
# (1)各種類の最も美味しさが高い寿司グループ
# (2)それ以外の寿司グループ
# をいずれも降順に並べて、(1)から幾つ取るか(最低でも1つは取る)を全探索する
import sys
readline = sys.stdin.readline

N,K = map(int,readline().split())

from collections import defaultdict
sushi = defaultdict(list) # 種類・おいしさ　のdictionary

for i in range(N):
  t,d = map(int,readline().split())
  sushi[t].append(d)
  
best_sushi = []
other_sushi = []

for value in sushi.values():
  value = sorted(value, reverse = True)
  best_sushi.append(value[0])
  other_sushi += value[1:]

best_sushi = sorted(best_sushi, reverse = True)
other_sushi = sorted(other_sushi, reverse = True)

#print("best_sushi",best_sushi)
#print("other_sushi",other_sushi)

best_num = 1 # best_sushiから選ぶ個数
other_num = K - 1 # other_sushiから選ぶ個数

if len(other_sushi) < other_num: # 選べない場合
  other_num = len(other_sushi)
  best_num = K - other_num
  
# それぞれの寿司から選ぶ個数の開始値が決定
# other_sushiの後ろの要素は切り離して良い

other_sushi = other_sushi[:other_num]
  
sushi_point = sum(best_sushi[:best_num]) + sum(other_sushi)
kind_point = best_num ** 2

ans = sushi_point + kind_point
#print("初期値",ans,"sum(best_sushi[:best_num])",sum(best_sushi[:best_num]),"sum(other_sushi)",sum(other_sushi),"best_num ** 2",best_num ** 2)

# best寿司のインデックスを進めていく
for i in range(best_num, len(best_sushi)):
  sushi_point += best_sushi[i]
  #print("----best_sushi[i]",best_sushi[i],"を追加")
  if len(other_sushi) == 0:
    break
  rem = other_sushi.pop() # 取り除く寿司
  sushi_point -= rem
  kind_point = (i + 1) ** 2
  
  #print("sushi_point",sushi_point,"kind_point",kind_point,"合計",sushi_point + kind_point)
  
  if ans < sushi_point + kind_point:
    ans = sushi_point + kind_point
    
print(ans)

Measured memory_bytes: 32156
#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;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"


template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef cc_hash_table<int, int, hash<int > > ht;


#define int long long 
#define  st first
#define  nd second

const int M = 1000000007;
const int  maxn = 100001;
const int  inf =  1e16;

void run_tests(){

  string s ; 
  cin >> s ; 
  int n = s.size();
  if(s[n-1]=='s'){
    cout << s+"es";
  }
  else{
    cout << s+"s";
  }
  


}
int32_t main(){

  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);

  int te=1 ; 
  //cin >> te ; 
  while(te--){
    run_tests();
  }
  
  }

  
  

Measured memory_bytes: 3660
// finish date: 2019/1/26

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1000000007;
const long long INFll = 100000000000000000;


vvi warshall_floyd(vvi dist) {
    int n = dist.size();
    for (int k = 0; k < n; k++) {       // 経由する頂点
        for (int i = 0; i < n; i++) {    // 始点
            for (int j = 0; j < n; j++) {  // 終点
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
    return dist;
}

int main() {
    int H, W;
    cin >> H >> W;
    vs S(H);
    rep(i, H) cin >> S[i];
    int N = H * W;
    vvi dist(N, vi(N, INF));
    rep(i, N) dist[i][i] = 0;
    rep(i, H) {
        rep(j, W) {
            if (S[i][j] == '#') continue;
            int x[] = {-1, 0, 1, 0};
            int y[] = {0, -1, 0, 1};
            rep(k, 4) {
                if ((0 <= i + y[k] and i + y[k] < H) and
                    (0 <= j + x[k] and j + x[k] < W) and
                    (S[i + y[k]][j + x[k]] == '.')) {
                    dist[i * W + j % W][(i + y[k]) * W + (j + x[k]) % W] = 1;
                }
            }
        }
    }


    dist = warshall_floyd(dist);
    int ma = 0;
    rep(i, N) {
        rep(j, N) {
            if (dist[i][j] != INF)
                ma = max(ma, dist[i][j]);
        }
    }
    cout << ma <<endl;

    return 0;
}


Measured memory_bytes: 1536
function Main(input){
  input  = input.split('\n');

  const HWD = input[0].split(' ')
    .map(x => Number(x));
  const H = HWD[0];
  const W = HWD[1];
  const D = HWD[2];

  let px = (new Array(90001)).fill(0);
  let py = (new Array(90001)).fill(0);

  for(let i=1; i<H+1; i++){
    const al = (input[i].split(' ').map(x => Number(x)));
    for(let j=0; j<al.length; j++){
      px[al[j]] = i-1;
      py[al[j]] = j;
    }
  }

  let d = (new Array(90001)).fill(0);
  for(let i=D+1; i<=H*W; i++){
    d[i] = d[i-D] + Math.abs(px[i]-px[i-D]) + Math.abs(py[i]-py[i-D]);
  }

  const Q = input[H+1];

  let L = new Array();
  let R = new Array();
  for(let i=H+2; i<input.length; i++){
    const LR = input[i].split(' ').map(x => Number(x));
    L.push(LR[0]);
    R.push(LR[1]);
  }

  for(let i=0; i<Q; i++){
    console.log(d[R[i]] - d[L[i]]);
  }
}
}

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


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

using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b;
	int i = 1;
	for (; b > 0; b /= 10, i *= 10) {
		c += (b % 10) * i;
	}
	b = a;
	for (; b > 0; b /= 10, i *= 10) {
		c += (b % 10) * i;
	}
	for (i = 1; i * i <= c; i++);
	i--;
	if (i * i == c) cout << "Yes";
	else cout << "No";
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		 Scanner sc = new Scanner(System.in);
		 String s = sc.next();
		 char [] str = s.toCharArray();
		 for(int i=0;i<str.length;i++) {
			 if((i+2)%2 == 0) {
				 System.out.print(str[i]);
			 }
		 }
		 sc.close();
	}
}

Measured memory_bytes: 31316
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
#pragma GCC optimize("O3")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 300*1000+15;
const ll N2      = 70;
const ld PI  = 3.141592653589793;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> tree_set;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}
signed main()
{
    fastio();
    //cout<<fixed<<setprecision(20);
    //CHECK for LONG LONG and LONG DOUBLE
    /*comment for all except cc/cf    
    #ifndef ONLINE_JUDGE    
           freopen("input.txt","r",stdin);
           freopen("output.txt","w",stdout);
    #endif//*/
    int n,k;
    cin>>n>>k;
    int a[n];
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i];
    }
    sort(a,a+n,greater<int>());
    int ans(0);
    for (int i = 0; i < n; ++i)
    {
        if(k)
        {
            k--;
            continue;
        }
        ans+=a[i];
    }
    cout<<ans;
}

Measured memory_bytes: 1792
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.IOException;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		double mksOne = 0;
		double mksTwo = 0;
		double mksThree = 0;
		double mksMax = 0;
		String[] strX = br.readLine().split(" ");
		String[] strY = br.readLine().split(" ");
		for (int i = 0; i < n; i++) {
			mksOne += Math.abs(Integer.parseInt(strX[i]) - Integer.parseInt(strY[i]));
			mksTwo += Math.pow(Math.abs(Integer.parseInt(strX[i]) - Integer.parseInt(strY[i])), 2);
			mksThree += Math.pow(Math.abs(Integer.parseInt(strX[i]) - Integer.parseInt(strY[i])), 3);
			if (mksMax < Math.abs(Integer.parseInt(strX[i]) - Integer.parseInt(strY[i]))) {
				mksMax = Math.abs(Integer.parseInt(strX[i]) - Integer.parseInt(strY[i]));
			}
		}
		System.out.println(mksOne);
		System.out.println(Math.sqrt(mksTwo));
		System.out.println(Math.cbrt(mksThree));
		System.out.println(mksMax);
	}
}

Measured memory_bytes: 24900
#include <stdio.h>
    #include <stdlib.h>

  int compare(const void *a,const void *b){
    return *(int *)a-*(int *)b;
  }

  int main(){
    int N;
    int a[100000];
    int i;
    int c;
    c=0;
    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%d",&a[i]);
        if(a[i]!=0){
            c=1;
        }
    }

    if(c==0){
        printf("Yes");
        return 0;
    }

    if(N%3!=0){
        printf("No");
        return 0;
    }

    qsort(a,N,sizeof(int),compare);
    if(a[0]!=a[N/3-1]||a[N/3]!=a[2*N/3-1]||a[2*N/3]!=a[N-1]){
        printf("No");
        return 0;
    }
    if((int)(a[0]^a[2*N/3])==a[N/3]){
        printf("Yes");
        return 0;
    }
    printf("No");
    return 0;
}

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

int main(){
  int N; cin >> N;
  int V[25], C[25];
  for(int i = 0; i < N; i++) cin >> V[i];
  for(int i = 0; i < N; i++) cin >> C[i];
  
  //宝石の価値が最大になるように取る
  //コストが最小になるように取る
  //差が正になるものだけ取る
  int ans = 0;
  for(int i = 0; i < N; i++){
    if(V[i] > C[i]){
      ans += V[i] - C[i];
    }
  }
  
  cout << ans << endl;
}

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

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int t0 = 0, x0 = 0, y0 = 0;
		int t, x, y;
		cin >> t >> x >> y;
		int dt = t - t0;
		int dx = x - x0;
		int dy = y - y0;
		if (abs(dx) + abs(dy) > abs(dt)) {
			cout << "No" << endl;
			return 0;
		}
		if ((dx + dy) % 2 != dt % 2) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#define ll long long
#define re register
#define il inline
#define pb push_back
#define fp(i,a,b) for(re int i=a;i<=b;++i)
#define fq(i,a,b) for(re int i=a;i>=b;--i)
using namespace std;
const int N=2e5+100,mod=1e9+7;
int n,x,X,Y,mn[N],mn1=mod,mn2=mod,ans=1,inv[N],tot;
vector<int>V[N];
il ll gi()
{
  re ll x=0,t=1;
  re char ch=getchar();
  while(ch!='-'&&(ch<'0'||ch>'9')) x=x*10+ch-48,ch=getchar();
  if(ch=='-') t=-1,ch=getchar();
  while(ch>='0'&&ch<='9') x=x*10+ch-48,ch=getchar();
  return x*t;
}
int main()
{
  n=gi();X=gi();Y=gi();
  inv[0]=inv[1]=1;
  fp(i,1,n) x=gi(),V[x].pb(gi());
  fp(i,2,n) inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
  fp(i,2,n) inv[i]=1ll*inv[i]*inv[i-1]%mod;
  fp(i,1,n)
    if(V[i].size())
      {
    sort(V[i].begin(),V[i].end());
        mn2=min(mn2,mn[i]=V[i][0]);
    if(mn2<mn1) swap(mn1,mn2);
      }
    else mn[i]=mod;
  fp(i,1,n)
    {
      re int mm=(mn[i]==mn1?mn2:mn1),sz=V[i].size();
      while(sz>1&&V[i][sz-1]+mm>Y&&V[i][sz-1]+mn[i]>X) --sz;
      if(mm+mn[i]<=Y) ans=1ll*ans*inv[sz]%mod,tot+=sz;
    }
  fp(i,1,tot) ans=1ll*ans*i%mod;
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 10880
#include <iostream>

using namespace std;

int main()
{
    int x, y;
    cin >> x >> y;

    int cnt = 0;
    for(int i = 0; i <= x; i++) {
        int diff = y - i*4 - (x-i)*2;
        if(diff == 0) {
            cnt++;
            break;
        }
    }

    if(cnt > 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';

#define MOD 1000000007
using namespace std;

ll banned[]={24, 25, 26, 27, 6, 70, 134, 198, 36, 37, 38, 39, 9, 73, 137, 201, 72, 73, 74, 75, 18, 82, 146, 210, 6, 22, 38, 54, 18, 22, 26, 30};

bool willbanned(ll in){
    bool ok=false;
    rep(i, 32){
        if(in==banned[i]) ok=true;
    }
    return ok;
}

int main(void){
    ll N;
    ll dp[100][256];
    cin>>N;
    MEMSET(dp, 0);
    dp[0][1]=1; dp[0][2]=1; dp[0][3]=1; dp[0][0]=1;
    rep(i, N-1){
        rep(j, 256){
            rep(k, 4){
                dp[i+1][(j*4)%256+k]+=dp[i][j];
                dp[i+1][(j*4)%256+k]%=MOD;
            }
        }
        if(i>=2) rep(j, 256){
            if(willbanned(j)) dp[i+1][j]=0;
            //cout<<dp[i+1][j]<<sp;
        }
        if(i==1) rep(j, 256){
            if(j==6 || j==18 || j==9) dp[i+1][j]=0;
            //cout<<dp[i+1][j]<<sp;
        }
        //cout<<endl;
    }
    ll count=0;
    rep(i, 256){
        count+=dp[N-1][i];
        count%=MOD;
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 384
N = int(input())
A1 = input().split()
A2 = input().split()

max_point = 0
point = int(A1[0])
for i in range(N):
    for j in range(i):
        point += int(A1[1+j])
    for j in range(N-i):
        point += int(A2[i+j])

    if(point > max_point):
        max_point = point
    point = int(A1[0])


print(max_point)

Measured memory_bytes: 3064
N = int(input())
a = list(map(int,input().split()))
#
s = 0
l = 1
for i in range(N):
	if a[i-1] == a[i] and i!= 0:
		l += 1
	else:
		s += (l-(l%2))//2
		l = 1
#	print((i,a[i],l,s))
s += (l-(l%2))//2
print(s)
#print((i,a[i],l,s))


Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
#include<ctype.h>
 
 
int main(){
 
  char s[1000], c[10], r[1000];
  int q, i, j, a, b;
 
  scanf("%s", s);
  scanf("%d", &q);
  for(i=0;i<q;i++){
    scanf("%s", c);
    if(strcmp(c,"replace")==0){
      scanf("%d %d %s", &a, &b, r);
      for(j=a;j<=b;j++) s[j]=r[j-a];
    }else if(strcmp(c,"reverse")==0){
      scanf("%d %d", &a, &b);
      for(j=a;j<=b;j++) r[j-a]=s[j];
      for(j=0;j<b-a+1;j++) s[b-j]=r[j];
    }else if(strcmp(c, "print")==0){
      scanf("%d %d", &a, &b);
      for(j=a;j<=b;j++) printf("%c", s[j]);
      printf("\n");
    }
  }
 
  return 0;
}


Measured memory_bytes: 2112
#include <iostream>
using namespace std;
int main()
{
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    int range_x[2], range_y[2];
    range_x[0] = r;
    range_x[1] = W - r;
    range_y[0] = r;
    range_y[1] = H - r;
    if (range_x[0] > x || range_x[1] < x || range_y[0] > y || range_y[1] < y)
    {
        cout << "No" << endl;
    }else
    {
        cout << "Yes" << endl;
    }
}



Measured memory_bytes: 3120
def decrease(K: int)->list:
    ret = [i + (K//50) for i in range(50)]
    for i in range(K % 50):
        for j in range(50):
            if j == i:
                ret[j] += 50
            else:
                ret[j] -= 1

    return ret


if __name__ == "__main__":
    K = int(input())
    ans = decrease(K)
    print(len(ans))
    print(' '.join(map(str, ans)))


Measured memory_bytes: 3060
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = LLONG_MAX, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W;
typedef long long ll;
typedef pair<ll, ll> Pa;

char char_map[100][100];
int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, dy[8] = {1, 1, 0, -1, -1, -1, 0, 1};

int main() {
    cin >> B >> A;
    rep(i, 50){
        rep(j, 100){
            char_map[i][j] = '.';
            char_map[i+50][j] = '#';
        }
    }
    int curr_x = 0, curr_y = 0;
    while(A > 1){
        bool flag = true;
        rep(i, 8){
            int x = curr_x + dx[i], y = curr_y + dy[i];
            if(x < 0 || 99 < x || y < 0 || 99 < y) continue;
            flag &= (char_map[y][x] == '.'); 
        }
        if(flag){
            char_map[curr_y][curr_x] = '#';
            A--;
        }
        curr_x++;
        if(curr_x == 100){
            curr_x = 0;
            curr_y++;
        }
    }

    curr_x = 99, curr_y = 99;
    while(B > 1){
        bool flag = true;
        rep(i, 8){
            int x = curr_x + dx[i], y = curr_y + dy[i];
            if(x < 0 || 99 < x || y < 0 || 99 < y) continue;
            flag &= (char_map[y][x] == '#'); 
        }
        if(flag){
            char_map[curr_y][curr_x] = '.';
            B--;
        }
        curr_x--;
        if(curr_x == -1){
            curr_x = 99;
            curr_y--;
        }
    }

    cout << 100 << " " << 100 << endl;
    rep(i, 100){
        rep(j, 100){
            cout << char_map[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1000000007, INF = 1e9;

int main()
{
    ll n, ans = 0;
    cin >> n;
    vector<ll> v(n), h(n), l(n);
    rep(i, n) cin >> v[i];
    rep(i, n) cin >> h[i];
    rep(i, n) cin >> l[i];
    sort(v.begin(), v.end());
    sort(h.begin(), h.end());
    sort(l.begin(), l.end());
    for(int i = 0; i < n; i++){
        auto a = lower_bound(v.begin(), v.end(), h[i]);
        auto b = upper_bound(l.begin(), l.end(), h[i]);
        ll k = a-v.begin();
        ll y = l.end()-b;
        ans += k*y;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2688
n,k=map(int,raw_input().split())
D=map(int,raw_input().split())
while 1:
    cnt=0
    for i in str(n):
        if int(i) in D:break
        else:
            cnt+=1
    if cnt==len(str(n)):
        print(n)
        quit()
    n+=1

Measured memory_bytes: 2692
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
string str(ll i) {
    return i < 0 ? "" : str((i / 26) - 1) + (char)(65 + i % 26);
}
int main()
{
   ll n,k;
   cin>>n;
   ll a[n];
   ll s=0;
   map<ll,ll>mp;
   for(ll i=0;i<n;i++)
   {
       cin>>a[i];
       s+=a[i];
       mp[a[i]]++;
   }
   cin>>k;
   while(k--)
   {
       ll x,y;
       cin>>x>>y;
       s=s-mp[x]*x+y*mp[x];
       mp[y]+=mp[x];
       mp[x]=0;
       cout<<s<<endl;
       
   }
   
}

Measured memory_bytes: 10320
// https://atcoder.jp/contests/abc077/tasks/arc084_a

#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <iomanip>

using namespace std;

int main (int argc, char* argv[]) {
	long long n;
	cin >> n;

	vector<vector<long long>> parts(3, vector<long long>(n));
	for (int i = 0; i < 3; i++) {
		for (auto j = 0ll; j < n; j++) {
			cin >> parts[i][j];
		}
		sort(parts[i].begin(), parts[i].end());
	}

	long long res = 0;
	for (long long i = 0; i < n; i++) {
		auto m_size = parts[1][i];
		auto top_patterns = distance(parts[0].begin(), upper_bound(parts[0].begin(), parts[0].end(), m_size - 1));
		auto bottom_patterns = distance(lower_bound(parts[2].begin(), parts[2].end(), m_size + 1), parts[2].end());
		res += top_patterns * bottom_patterns;
	}

	cout << res << endl;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define vecread(v) for(auto& e: v){cin >> e;}
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long int ll;
typedef vector<int >    vecint;
typedef vector<ll >      vecll;
typedef vector<double >   vecd;
typedef vector<string > vecstr;
typedef vector<char >  vecchar;
typedef vector<bool >  vecbool;
typedef vector<vector<bool> >  vec2bool;
typedef vector<vector<int> >    vec2int;
typedef vector<vector<double> >   vec2d;
////////////////////////////////////////////////
void init(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
////////////////////////////////////////////////
int main()
{
  init();
  int n; cin >> n;
  vecint a(n,0); vecread(a);
  ll num1, num2;
  ll sum1, sum2;
  num1 = num2 = 0;
  sum1 = sum2 = 0;
  //////// plus
  if(a[0] <= 0){
    num1 = -a[0] + 1;
    sum1 = 1;
  }else{
    num1 = 0;
    sum1 = a[0];
  }
  // cout << a[0] << " " << sum1 << " " << num1 << endl;
  for(int i = 1; i < n ; i ++){
    if(sum1 > 0){
      if(sum1 + a[i] >= 0){
	num1 += a[i] + sum1 + 1;
	sum1 = -1;
      }else{
	sum1 = sum1 + a[i];
      }
    }else{
      if(sum1 + a[i] <= 0){
	// cout << sum1  << " " << a[i] << " " << num1 + 1 - sum1 - a[i] << endl;
	num1 = num1 + 1 - sum1 - a[i];
	sum1 = 1;
      }else{
	sum1 = sum1 + a[i];
      }
    }
    // cout << a[i] << " " << sum1 << " "<< num1 << endl;
  }
  // cout << num1 << endl;
  //////// minus
  if(a[0] >= 0){
    num2 = a[0] + 1;
    sum2 = -1;
  }else{
    num2 = 0;
    sum2 = a[0];
  }
  for(int i = 1; i < n ; i ++){
    if(sum2 > 0){
      if(sum2 + a[i] >= 0){
	num2 += a[i] + sum2 + 1;
	sum2 = -1;
      }else{
	sum2 = sum2 + a[i];
      }
    }else{
      if(sum2 + a[i] <= 0){
	num2 += 1 - sum2 - a[i];
	sum2 = 1;
      }else{
	sum2 = sum2 + a[i];
      }
    }
  }
  cout << min(num1, num2) << endl;
}


Measured memory_bytes: 640
import bisect

n = int(input())
count = 0
a = [[0 for i in range(n)] for i in range(3)]

for i in range(3):
    a[i] = [int(x) for x in input().split()]
    a[i].sort()

# Binary Search
for i in a[1]:
    index0_left = bisect.bisect_left(a[0], i)

    index2_right = bisect.bisect_right(a[2], i)

    count += (index0_left -1 + 1)*(n - index2_right)

print(count)

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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define MOD 1000000007
typedef pair<li, li> PI;

int main(void)
{
	li a;
	cin >> a;
	cout << a*a*a << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()


def main():
    k, s = map(int, input().split())
    ans = 0
    for x in range(k + 1):
        for y in range(k + 1):
            if 0 <= s - x - y <= k: ans += 1
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 73180
def main():
    s = ["".join(sorted(i)) for i in open(0).read().split()[1:]]
    ans = 0
    d = {}
    for i in s:
        if i in d:
            ans += d[i]
            d[i] += 1
        else:
            d[i] = 1
    print(ans)
    return


main()


Measured memory_bytes: 21000
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let n = v[0];
	let mut blue:Vec<String> = Vec::new();
	for i in 0..n {
		let mut buf = String::new();
		io::stdin().read_line(&mut buf).expect("");
		blue.push(buf.trim().to_string());
	}
	
	let v:Vec<i32> = procon_read();
	let m = v[0];
	let mut red:Vec<String> = Vec::new();
	for i in 0..m {
		let mut buf = String::new();
		io::stdin().read_line(&mut buf).expect("");
		red.push(buf.trim().to_string());
	}
	let mut maxi = -200;
	let mut cnt = 0;
	for b in &blue {
		for i in 0..n {
			if *b == blue[i as usize] {
				cnt += 1;
			}
		}
		for i in 0..m {
			if *b == red[i as usize] {
				cnt -= 1;
			}
		}
		maxi = std::cmp::max(cnt, maxi);
		cnt = 0;
	}
	for r in &red {
		for i in 0..n {
			if *r == blue[i as usize] {
				cnt += 1;
			}
		}
		for i in 0..m {
			if *r == red[i as usize] {
				cnt -= 1;
			}
		}
		maxi = std::cmp::max(cnt, maxi);
		cnt = 0;
	}
	if maxi<0 {
		maxi = 0;
	}
	println!("{}", maxi);
}

Measured memory_bytes: 4476
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
 
#define mod 1000000007
#define inf 1000000000
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}

int main(){
  string s;
  cin >> s;
  ll k;
  cin >> k;

  set<string> t;
  for(ll i = 1; i <= k; i++){
    for(ll j = 0; j < s.size()-i+1; j++){
      string b = s.substr(j, i);
      t.insert(b);
    }
  }

  ll cnt = 1;
  for(auto x : t){
    if(cnt == k) cout << x << endl;
    cnt++;
  }
  return 0;
}

Measured memory_bytes: 1664
#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;

int main() {
	int n;
	cin >> n;
	vector<int> x(n), y(n);
	rep(i, n) cin >> x[i] >> y[i];
	vector<vector<double>> dist(n, vector<double>(n));
	rep(i, n) rep(j, n) {
		dist[i][j] = sqrt((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]));
	}
	vector<int> v(n);
	rep(i, n) v[i] = i;
	double ans = 0.0;
	int cnt = 0;
	do{
		double now = 0.0;
		rep(i, n-1) {
			now += dist[v[i]][v[i+1]];
		}
		ans += now;
		cnt++;
	}while(next_permutation(all(v)));
	printf("%.10f\n", ans/cnt);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>

#define PI_ 60*M_PI/180

struct P{
  double x,y;

  P (double x = 0 ,double y = 0) : x(x), y(y) {}

  P operator + (P p){
    return P(x + p.x , y + p.y);
  }

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

  P operator * (double k){
    return P(x * k , y * k);
  }

  P operator / (double k){
    return P(x / k , y / k);
  }
};

void solve(P p1,P p2,int end){
  if(end == 0){
    printf("%.8f %.8f\n" ,fabs(p1.x) ,fabs(p1.y));
    return;
  }

  P c = (p2 - p1) / 3, d = c * 2;
  P s = p1 + c , t = p1 + d;
  P u;

  u.x = s.x + (t.x - s.x) * cos(PI_) - (t.y - s.y) * sin(PI_);
  u.y = s.y + (t.x - s.x) * sin(PI_) + (t.y - s.y) * cos(PI_);

  solve(p1,s,end-1);
  solve(s,u,end-1);
  solve(u,t,end-1);
  solve(t,p2,end-1);

}

int main(){
  int n;
  P p1(0,0), p2(100,0);

  scanf("%d" ,&n);
  solve(p1,p2,n);
  printf("%.8f %.8f\n" ,p2.x ,p2.y);

  return 0;
}

Measured memory_bytes: 1068
#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;}
const ll INF = 1LL<<60;

int main()
{
  ll a[3];
  for(ll i=0;i<3;i++)cin>>a[i];
  sort(a,a+3);
  string ans="No";
  if(a[0]==a[1]&&a[1]!=a[2])ans="Yes";
  if(a[0]!=a[1]&&a[1]==a[2])ans="Yes";
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
S = input()

seikai1 = [0 if i%2==0 else 1 for i in range(len(S))]
seikai2 = [0 if i%2==1 else 1 for i in range(len(S))]
count1, count2 = 0, 0
for i in range(len(S)):
    x = int(S[i])
    if x != seikai1[i]:
        count1 += 1
for i in range(len(S)):
    x = int(S[i])
    if x != seikai2[i]:
        count2 += 1
print(min(count1, count2))

Measured memory_bytes: 4852
fun main(args: Array<String>) {
    val (N, M) = readLine()!!.split(" ").map(String::toInt)
    val P = Array(N) {
        val (A, B) = readLine()!!.split(" ").map(String::toLong)
        P(A, B)
    }
    P.sortBy { it.A }
    var c = 0L
    var m = 0L
    for (p in P) {
        c += p.A * Math.min(M - m, p.B)
        m += p.B
        if (M <= m) break
    }
    println(c)
}

data class P(val A: Long, val B: Long)

Measured memory_bytes: 75848
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

const int MAXN = 1e6 + 10;
const int Mod = 998244353;
int N, M;
int fac[MAXN], ifc[MAXN];
int ans;

inline int fastpow_mod(int a, int b = Mod - 2, int m = Mod) {
	int x = 1;
	while(b) {
		if(b & 1) x = 1ll * x * a % Mod;
		a = 1ll * a * a % Mod; b >>= 1;
	}
	return x;
}

inline void init(int n) {
	register int i;
	for(fac[0] = i = 1; i <= n; ++i) fac[i] = 1ll * fac[i - 1] * i % Mod;
	for(ifc[n] = fastpow_mod(fac[n]), i = n; i; --i) ifc[i - 1] = 1ll * ifc[i] * i % Mod;
}

inline int C(int n, int k) {
	return 1ll * fac[n] * ifc[n - k] % Mod * ifc[k] % Mod;
}

int main() {
	register int i;
	scanf("%d%d", &N, &M); init(N + M); if(N > M) swap(N, M);
	for(i = 1; i <= N; ++i) ans = (1ll * ans + 1ll * C(i * 2, i) * C(N + M - i * 2, M - i) % Mod) % Mod;
	ans = 1ll * ans * fastpow_mod(1ll * C(N + M, M) * 2 % Mod) % Mod;
	ans = (1ll * ans + M) % Mod;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 7936
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
import sys,bisect,string,math,time,functools,random
def Golf():*a,=map(int,open(0))
def I():return int(input())
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[];g=[[] for i in range(n)]
    for i in range(E):
        inp=LI();org_inp.append(inp)
        if index==0:inp[0]-=1;inp[1]-=1
        if len(inp)==2:
            a,b=inp;g[a].append(b)
            if not Directed:g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp;aa=(inp[0],inp[2]);bb=(inp[1],inp[2]);g[a].append(bb)
            if not Directed:g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):
#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[1]*(w+2);found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[1]+[mp_def[j] for j in s]+[1]
    mp+=[1]*(w+2)
    return h+2,w+2,mp,found
def TI(n):return GI(n,n-1)
def bit_combination(k,n=2):return [[tb//(n**bt)%n for bt in range(k)] for tb in range(n**k)]
def show(*inp,end='\n'):
    if show_flg:print(*inp,end=end)

YN=['YES','NO'];Yn=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
#sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()

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

show_flg=False
show_flg=True

ans=0

h,w=LI()

h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
#show(g,h,w,sg)


dp=[10**6]*(h*w)
#dp[1*w+1]=0
dp[1]=0
g[1]=0

'''
for i in range(h):
    show(g[i*w:(i+1)*w])
'''

for j in range(h*w-h):
    r,c=j//w,j%w
    
    if 1<=r<=h-2 and 1<=c<=w-2:
        pass
    else:
        if j==1:
            pass
        else:
            continue
    
    #if dp[j]>=10**6:continue
    
    dp[j+1]=min(dp[j]+1 if (g[j],g[j+1])==(0,1) else dp[j],dp[j+1])
    dp[j+w]=min(dp[j]+1 if (g[j],g[j+w])==(0,1) else dp[j],dp[j+w])


print(dp[(h-2)*w+w-2])


Measured memory_bytes: 43496
import java.util.Scanner;
import java.math.BigDecimal;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        BigDecimal a = sc.nextBigDecimal();
        double b = sc.nextDouble();
        sc.close();
 
        BigDecimal ans = a.multiply(BigDecimal.valueOf(b));
        System.out.println(ans.longValue());
    }
}


Measured memory_bytes: 37736