akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}  
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: String,
    }

    let s = n.contains('7'); 
    if s {
        println!("Yes");
    } else {
        println!("No")
    }
}


Measured memory_bytes: 2084
#include <stdio.h>
int main() {
	int x, y, money = 0;
	scanf("%d%d", &x, &y);
	if (x <= 3) {
		money += (4 - x) * 100000;
	}
	if (y <= 3) {
		money += (4 - y) * 100000;
	}
	if (x == 1 && y == 1) {
		money += 400000;
	}
	printf("%d\n", money);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int k[60][60]={0};
int main()
{
	int n,m,i,j,flag=0,c;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m+1;j++)
		{
			scanf("%c",&c);
			if(c=='#')
				k[i][j]=1;
			else
				k[i][j]=0;
		}
	}
	/*for(i=1;i<=n+1;i++)
	{
		for(j=2;j<=m;j++)
		{
			printf("%d %d %d\n",i,j,k[i][j]);
		}
	}*/
	for(i=1;i<=n+1;i++)
	{
		for(j=2;j<=m;j++)
		{
			if(k[i][j]==1)
			{
				if(k[i-1][j]==1||k[i][j-1]==1||k[i+1][j]==1||k[i][j+1]==1)
				{
				}
				else
				{
					printf("No");
					flag=1;
					break;
				}
			}
		}
		if(flag==1)
			break;
	}
	if(flag==0)
		printf("Yes");	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

//単調増加なので二分探索でできる
//以下は尺取法を行っている
int main(){
    ll n, m, k;
    cin >> n >> m >> k;
    vector<int> a(n);
    vector<int> b(m);
    rep(i,n) cin >> a[i];
    rep(i,m) cin >> b[i];

    ll t=0;
    rep(i,m) t+= b[i];

    int j=m;
    int ans=0;
    //i(A側)とj(B側)の2つのカーソルを追う
    rep(i,n+1){
        //合計時間tがkを超えていたら１つずつ諦める
        while(j>0 && t>k){
            --j;
            t -= b[j];
        }
        //もう諦められる本がない(j=0)かつt>kならbreak
        if(t>k) break;
        ans = max(ans,i+j);
        //配列外参照を防ぐためにbreakで誤魔化している
        if(i==n) break;
        t+= a[i];
    }

    cout << ans << endl;
    return 0;
   


}

Measured memory_bytes: 4808
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define print(a) cout << (a) << endl; 
typedef long long ll;
const int MOD = 1000000007; 

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> size;
    UnionFind(int N) : par(N), size(N, 1) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        par[x] = root(par[x]);
        return par[x];
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        size[ry] += size[rx];
    }

    int get_size(int x) {
        int rx = root(x);
        return size[rx];
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
 
int main() {
    int n, m, k;
    cin >> n >> m >> k;
    UnionFind uf(n);
    vector<int> fcnts(n, 0); 
    vector<vector<int>> ks(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        uf.unite(a, b);
        fcnts[a]++; fcnts[b]++;
    }
    rep(i, k) {
        int c, d;
        cin >> c >> d;
        c--; d--;
        ks[c].push_back(d);
        ks[d].push_back(c);
    }
    vector<int> rets(n);
    rep(i, n) {
        int c = -1; 
        c += uf.get_size(i);
        c -= fcnts[i];
        for (int k : ks[i]) {
            if (uf.same(i, k)) c--;
        }
        rets[i] = c;
    }
    rep(i, n) cout << rets[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 8448
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;

ll nCr(ll n, ll r) {
	if (r > n) { return 0; }
	if (r * 2 > n) r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i) {
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
ll sumdigit(ll n) {
	ll dig = 0, sum = 0;
	while (n) {
		dig = n % 10;
		sum = sum + dig;
		n = n / 10;
	}
	return sum;
}


int main() {
	int h = 0, w = 0;
	int count = 0;
	char map[100][100] = {};
	int tate[100] = {}, yoko[100] = {};
	std::cin >> h >> w;
	rep(i, h) {
		rep(j, w) {
			std::cin >> map[i][j];
			if (map[i][j] == '.') {
				tate[i]++;
				yoko[j]++;
			}
		}
	}
	rep(i, h) {
		rep(j, w) {
			if (tate[i] != w && yoko[j] != h) {
				std::cout << map[i][j];
				count++;
			}
		}
		if (count != 0) {
			std::cout << std::endl;
		}
		count = 0;
	}

	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n;
	cin >> n;

	vi cnt(n);
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (a & 1) {
			cout << 0 << endl;
			return 0;
		}

		while (a % 2 == 0) {
			a /= 2;
			cnt[i]++;
		}
	}

	sort(cnt.begin(), cnt.end());

	cout << cnt[0] << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> PII;
#define fi first
#define se second
#define MP make_pair

int read()
{
    int v = 0, f = 1;
    char c = getchar();
    while (c < 48 || 57 < c) {if (c == '-') f = -1; c = getchar();}
    while (48 <= c && c <= 57) v = (v << 3) + v + v + c - 48, c = getchar();
    return v * f;
}

const int N = 1000000;
const ll MOD = 1e9 + 7;
int n;
ll fac[N], a[N], b[N], ans;

ll pw(ll a, ll b)
{
    ll re = 1;
    while (b)
    {
        if (b & 1)
            re = re * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return re;
}

int main()
{
    n = read();
    for (int i = 1; i <= n; i++) a[i] = read();
    fac[0] = 1;
    for (int i = 1; i <= n; i++)
        fac[i] = fac[i - 1] * i % MOD;
    ll ans = 0;
    for (int i = 1; i <= n; i++)
        ans = (ans + fac[n] * a[i] % MOD) % MOD;
    for (int i = 1; i <= n; i++)
        b[i] = fac[n] * pw(i, MOD - 2) % MOD;
    b[1] = 0;
    for (int i = 2; i <= n; i++)
        b[i] = (b[i - 1] + b[i]) % MOD;
    for (int i = 1; i <= n; i++)
        ans = (ans + a[i] * b[i] % MOD + a[i] * b[n - i + 1] % MOD) % MOD;
    printf("%lld\n", ans);
}


Measured memory_bytes: 9216
/*
//alds1_4_c:Dictionary
//算法:开放地址法散列表
//Time: 2018/1/8 星期一
*/
#include<stdio.h>
#include<string.h>

const int M=1000003;
const int L=14;

char H[M][L];

//对于每个字符返回的定义值
int getChar(char ch){
    if(ch=='A') return 1;
    if(ch=='C') return 2;
    if(ch=='D') return 3;
    if(ch=='T') return 4;
    return 0;
}
//对于字符串返回的初始散列值
long long getKey(char str[]){
    long long len=strlen(str),sum=0,p=1;
    for(int i=0;i<len;++i){
        sum+=p*getChar(str[i]);
        //每次获取定义值后p*5,相当于转换成五进制,不会冲突
        p*=5;
    }
    return sum;
}

//开放式散列值计算式: h(k,i)=(h1(k)+i*h2(k))%M
int h1(int key){
    return key%M;
}
//为了保证不会递归冲突(即往下算结果始终相同),必须使h2(key)与M互素
//TLE最好的情况就是改这个函数= =
//目前可以AC的: 1+(key%(M-1))
//(1+key)%(M-1)
int h2(int key){
    return (1+key)%(M-1);
}

//查找
//-1表示找到
//h表示找到第一个可插入点
int find(char str[]){
    long long key=getKey(str),i,h;
    for(i=0;;++i){
        h=(h1(key)+i*h2(key))%M;
        if(strcmp(H[h],str)==0) return -1;
        else if(strlen(H[h])==0) return h;
    }
    return 0;
}

//插入
void insert(char str[]){
    int key=find(str);
    if(key!=-1) strcpy(H[key],str);
}

int main(){
    for(int i=0;i<M;++i) H[M][0]='\0';
    char str[L],com[L];
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;++i){
        scanf("%s %s",com,str);

        if(com[0]=='i'){
            insert(str);
        }else{
            if(find(str)==-1)
                printf("yes\n");
            else
                printf("no\n");
        }
    }

    return 0;
}



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

int main() 
{
  int N;
  cin >> N;
  double len = 0.0;
  unsigned int cases = 0;
  double ans = 0.0;
  
  vector< pair<int, int> > city(N, pair<int, int>());
  for (int i = 0; i < N; i++) {
    cin >> city.at(i).first >> city.at(i).second;
  }
  
  for (int i = 0; i < N - 1; i++) {
    for (int j = i + 1; j < N; j++) {
      len += sqrt((city.at(j).first - city.at(i).first) * (city.at(j).first - city.at(i).first)
                  +(city.at(j).second - city.at(i).second) * (city.at(j).second - city.at(i).second));
    }
  }
  ans =  len * 2 / (double)N;
  cout << setprecision(12) << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
int h,w,x,y,nx,ny,t,r,a[1010][1010],dx[]={0,1,0,-1},dy[]={1,0,-1,0};
char c;
queue<tuple<int,int,int>>q;
main(){
  cin>>h>>w;
  rep(i,h)rep(j,w){
    cin>>c;
    a[i][j]=1000000;
    if(c=='#')q.emplace(i,j,0);
  }
  while(!q.empty()){
    tie(y,x,t)=q.front();q.pop();
    if(a[y][x]>t){
      a[y][x]=t;
      r=max(r,t);
      rep(i,4){
        ny=y+dy[i];nx=x+dx[i];
        if(!(nx<0||ny<0||nx>=w||ny>=h))q.emplace(ny,nx,t+1);
      }
    }
  }
  cout<<r;
}

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

using namespace std;
using ll = long long;
#define int ll
using PII = pair<int, int>;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<V<T>>;
template <typename T> using VVV = vector<VV<T>>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll INF = (1LL<<60);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int n;
  cin >> n;
  V<int> a(n);
  REP(i, n) cin >> a[i];
  V<int> b(a);
  
  int ret = 0;
  int turn = 0;
  FOR(i, 1, n) {
    // i番目の増減が正しくない
    if(turn == 0) {
      if(a[i-1] < a[i]) {
        // 次が増加ならi-1とi
        // 次が減少ならiとi+1
        if(i+1 >= n || a[i] < a[i+1]) {
          swap(a[i-1], a[i]);
          ret++;
        } else {
          swap(a[i], a[i+1]);
          ret++;
        }
      }
    } else {
      if(a[i-1] > a[i]) {
        // 次が減少ならi-1とi
        // 次が増加ならiとi+1
        if(i+1 >= n || a[i] > a[i+1]) {
          swap(a[i-1], a[i]);
          ret++;
        } else {
          swap(a[i], a[i+1]);
          ret++;
        }
      }
    }
    turn = !turn;
    // cout << i << " " << turn << " " << a << endl;
  }
  // cout << a << endl;

  a = b;
  int ans = ret;
  ret = 0, turn = 1;
    FOR(i, 1, n) {
    // i番目の増減が正しくない
    if(turn == 0) {
      if(a[i-1] < a[i]) {
        // 次が増加ならi-1とi
        // 次が減少ならiとi+1
        if(i+1 >= n || a[i] < a[i+1]) {
          swap(a[i-1], a[i]);
          ret++;
        } else {
          swap(a[i], a[i+1]);
          ret++;
        }
      }
    } else {
      if(a[i-1] > a[i]) {
        // 次が減少ならi-1とi
        // 次が増加ならiとi+1
        if(i+1 >= n || a[i] > a[i+1]) {
          swap(a[i-1], a[i]);
          ret++;
        } else {
          swap(a[i], a[i+1]);
          ret++;
        }
      }
    }
    // cout << i << " " << turn << " " << a << endl;
    turn = !turn;
  }

  chmin(ans, ret);
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 4448
n = int(input())
ac, wa, tle, re = 0, 0, 0, 0

for i in range(n):
    a = input()
    if a == "AC":
        ac += 1
    if a == "WA":
        wa += 1
    if a == "TLE":
        tle += 1
    if a == "RE":
        re += 1

print('AC x {}'.format(ac))
print('WA x {}'.format(wa))
print('TLE x {}'.format(tle))
print('RE x {}'.format(re))


Measured memory_bytes: 9044
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define pb push_back
#define mp make_pair
#define ll long long
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define testcase ll T; cin >> T; for (ll tc = 1; tc <= T; tc++)
#define M 1000000007
#define MM 998244353
#define eps 1e-8
#define eq(x,y) (fabs((x)-(y)) < eps)
#define r2 1.41421356237
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod;assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

int main()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  //testcase {
  ll d,t,s;
  cin>>d>>t>>s;
  if(s*t>=d) { cout<<"Yes"; }
  else { cout<<"No"; }
  //}  
  return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int H, N;
	cin >> H >> N;
	int sum = 0;
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		sum += A;
	}
	if (sum >= H) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

int main(){
  int N; cin >> N;
  int cnt = 0, prv = -1, ans = 0;
  for(int i = 0; i < N; i++){
    int tmp; cin >> tmp;
    if(prv == tmp) cnt++;
    else{
      ans += cnt/2;
      cnt = 1;
    }
    prv = tmp;
  }
  ans += cnt/2;
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Collections;
public class Remainder {
    static long div = 1000000007;
    static public void Main() {
        
        var N  = int.Parse(Console.ReadLine());
        var P =　Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        //var mins = new int[N];
        var min  = long.MaxValue;
        var count = 0;
        for(int i = 0;i < N;i++){
            if(P[i] < min){
                min = P[i];
                count++;
            }
            
        }
        Console.WriteLine(count); 
            
    }
    
} 


Measured memory_bytes: 36420
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    SS = S()

    if SS=='ABC':
        print('ARC')
    else:
        print('ABC')

if __name__ == '__main__':
    resolve()

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

int main(){
    int n,s;
    string str;
    cin >> n;
    getline(cin,str);
    for(int i=0;i<n;i++){
        getline(cin,str);
        s=str.size();
        for(int i=0;i<s;i++){
            if(str[i]=='H'&&str[i+1]=='o'&&str[i+2]=='s'&&
                   str[i+3]=='h'&&str[i+4]=='i'&&str[i+5]=='n'&&str[i+6]=='o'){
                str[i+6]='a';
            }
        }
        //if(str=="")cout << "HOOGE" << endl;
        cout << str << endl;
    }
    return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll a,b;
	scanf("%lld%lld",&a,&b);
	if((a+b)%2==0){
		printf("%lld\n",(a+b)/2);
	}
	else{
		printf("IMPOSSIBLE\n");
	}
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>

int n,m,d;

int main(){
	scanf("%d%d%d",&n,&m,&d);
	double x=2.0*(n-d)/((long long)n*n)*(m-1);
	if(d==0){
		printf("%.10lf",(double)(m-1)/n);
	}
	else printf("%.10lf",x);
	return 0;
}

Measured memory_bytes: 128
#!python3

# input
N, M = list(map(int, input().split()))
P = [None] + list(map(int, input().split()))
X, Y = [None] * M, [None] * M
for i in range(M):
    X[i], Y[i] = list(map(int, input().split()))


def main():
    S = [{i} for i in range(N + 1)]
    G = list(range(N + 1))
    for i in range(M):
        g1, g2 = G[X[i]], G[Y[i]]
        if g1 == g2:
            continue
        if len(S[g1]) < len(S[g2]):
            g1, g2 = g2, g1
        S[g1] |= S[g2]
        for j in S[g2]:
            G[j] = g1

    visit = [False] * (N + 1)
    ans = 0
    for i in range(1, N + 1):
        if visit[i]:
            continue
        s = S[G[i]]
        for j in s:
            visit[j] = True
            if P[j] in s:
                ans += 1
    
    print(ans)
    

if __name__ == "__main__":
    main()


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

int main() {
  int n, a = 0, k;
  cin >> n;
  k = n;
  while(k > 0){
    a += k % 10;
    k /= 10;
  }
  if(n % a == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void){

  int n;
  scanf("%d", &n);
  long x[n],y[n];
  for (int i = 0; i < n; i++) {
    scanf("%ld %ld", &x[i], &y[i]);
  }
  double sum = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i+1; j < n; j++) {
      sum += sqrt((x[j]-x[i])*(x[j]-x[i])+(y[j]-y[i])*(y[j]-y[i]));
    }
  }
  double answer = sum*2.0;
  answer /= n*1.0;
  printf("%lf\n", answer);

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

const int N_MAX = 500001;

int h[N_MAX];

class KMP
{
public:
    string pattern;
    int plen;
    vector<int> table;
    KMP(const string s) : pattern(s), plen((int)pattern.size()), table(plen+1){
        table[0] = -1;
        int j = -1;
        for(int i = 0; i < plen; i++){
            while(j >= 0 && pattern[i] != pattern[j]) j = table[j];
            if(pattern[i+1] == pattern[++j]) table[i+1] = table[j];
            else table[i+1] = j;
        }
    }
    void search(const string& text, vector<int>& res){
        int head = 0, j = 0, tlen = (int)text.size();
        while(head + j < tlen){
            if(pattern[j] == text[head + j]){
                if(++j != plen) continue;
                res.push_back(head);
            }
            head += j - table[j], j = max(table[j], 0);
        }
    }
};

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int main(){
    string s, t;
    string S;
    cin >> s >> t;
    int n = 2*(t.size()+s.size()-1)/s.size();
    
    for(int i = 0; i <= n; i++){
        S += s;
    }
    vector<int> v;
    KMP kmp(t);
    kmp.search(S, v);
    UnionFind uf(s.size());
    
    for(int i = 0; i < v.size(); i++){
        if(v[i] < s.size()){
            if(!uf.findSet(v[i], (v[i]+t.size())%s.size())){
                uf.unionSet(v[i], (v[i]+t.size())%s.size());
            }else{
                cout << -1 << endl;
                return 0;
            }
        }
        // cout << v[i] << ' ';
    }
    // cout << endl;
    int ans = 0;
    for(int i = 0; i < s.size(); i++){
        ans = max(ans, uf.size(i)-1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 16576
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;


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

int main(){
    fast_io
    
    int h, w;
    cin>>h>>w;
    char s[h][w];
    bool flag=true;
    rep(i,h){
        rep(j,w){
            cin>>s[i][j];
        }
    }

    rep(i,h){
        rep(j,w){
            if(s[i][j]=='#'){
                flag=false;
                for(int k=0;k<4;k++){
                    int ny=i+dy[k];
                    int nx=j+dx[k];
                    if(nx>=0&&nx<w&&ny>=0&&ny<h){
                        if(s[ny][nx]=='#'){
                            flag=true;
                            break;
                        }
                    }
                }
                if(!flag){
                    cout<<"No"<<endl;
                    return 0;
                }
            }

        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#include <iostream>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;

#define pf(n) cout << n << endl
#define ps() cout <<" ";
#define sf(n) cin >> n
#define in(i,n) for (int i = 0; i < n; i++)
#define vi vector<int>
#define vp vector<pair<int, int>>
#define graph vector< vector<int> >
#define vs vector<string>
#define mn -
#define pls +
#define mod %
#define E =
#define EE ==
#define le <=
#define ge <=
int mx=9999999;
/**  '' "\n" - ^ **/

    void yes()
    {
        cout<<"Yes\n";
    }

    void no()
    {
        cout<<"No\n";
    }
    void YES()
    {
        cout<<"YES\n";
    }

    void NO()
    {
        cout<<"NO\n";
    }

    void Case(int i,int n)
    {
        cout<<"Case:"<<i<<" "<<n<<endl;
    }
    /**  '' "\n" x ^ **/
    /** printf("\n") */

    bool comp(pair<int,int> a,pair<int,int> b)
    {
        if(a.second != b.second)//return false;
        return a.first<b.first;
        return true;
    }
    int a,b,c,d;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    in(i,n)
    {
    	string str;
    	cin>>str;
    	if(str EE "AC")a++;
    	if(str EE "WA")b++;
    	if(str EE "TLE")c++;
    	if(str EE "RE")d++;
	}
	printf("AC x %d\n",a);
	printf("WA x %d\n",b);
	printf("TLE x %d\n",c);
	printf("RE x %d\n",d);
}


Measured memory_bytes: 3744
from operator import itemgetter
N,C = [int(x) for x in input().split()]
# list(time,action,channel) action = start:1, stop:0
actions = []
for _ in range(N):
    s,t,c = [int(x) for x in input().split()]
    actions.append((s-0.5, 1, c))
    actions.append((t, 0, c))
actions.sort(key=itemgetter(0))

cnt_now_rec = 0
# list to know the start time of rec. if channel not in rec, takes -1.
channel_now_rec = [-1] * (C+1)
ans = 0
for time,action,channel in actions:
    if(action == 1):
        if(channel_now_rec[channel]==-1):
            cnt_now_rec += 1
        channel_now_rec[channel] = time
    elif(action == 0):
        if(time == channel_now_rec[channel]+0.5):
            pass
        else:
            cnt_now_rec -= 1
            channel_now_rec[channel] = -1
    ans = max(ans,cnt_now_rec)
print(ans)


Measured memory_bytes: 27968
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn main() {
    let s: String = input();
    let s: Vec<char> = s.chars().collect();
    let t: String = input();
    let t: Vec<char> = t.chars().collect();    

    let mut table: Vec<Vec<u64>> = Vec::new();
    for i in 0..s.len() + 1 {        
        table.push(vec![0; t.len() + 1]);
    }

    for i in 0..s.len() {
        for j in 0..t.len() {
            if s[i] == t[j] {
                table[i + 1][j + 1] = table[i][j] + 1;
            } else {
                if table[i+1][j] > table[i][j+1] {
                    table[i+1][j+1] = table[i+1][j];
                } else {
                    table[i+1][j+1] = table[i][j+1];
                }
            }
            // println!("{}, {} -> {:?}", i+1, j+1, table[i+1][j+1]);
        }
    }
    // println!("{}", table[s.len()][t.len()]);

    // backtrace
    let mut i = s.len();
    let mut j = t.len();
    let mut ans: Vec<char> = Vec::new();
    while i > 0 && j > 0 {
        if table[i][j] == table[i-1][j] {
            i -= 1;
        } else if table[i][j] == table[i][j-1] {
            j -= 1;
        } else {
            i -= 1;
            j -= 1;
            ans.push(s[i]);
        }
    }
    ans.reverse();
    for c in ans {
        print!("{}", c);
    }
    println!();
}


Measured memory_bytes: 90364
#include <stdio.h>
#include <string.h>
int main(void)
{
    int n, l, i, j;
    char s[100][101], ans[100000] , tmp[101];

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

    for(j=0;j<n;j++){
        for(i=0;i<n-1;i++){
            if(strcmp(s[i], s[i+1])>0){
                strcpy(tmp, s[i]);
                strcpy(s[i], s[i+1]);
                strcpy(s[i+1], tmp);
            }
        }
    }
    
    for(i=0;i<n;i++){
        printf("%s", s[i]);
    }
    printf("\n");
    
    return 0;
}
            
    


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>b>>a;
	string st;
	cin>>st;
	vector<string> ans(a,string(b,'.'));
	for(int i=0;i<a;i++){
		ans[i][0]=ans[i][b-1]='|';
	}
	for(int i=0;i<b;i++){
		ans[0][i]=ans[a-1][i]='-';
	}
	ans[0][0]=ans[a-1][0]=ans[0][b-1]=ans[a-1][b-1]='+';
	ans[a/2][b/2]=st[0];
	for(int i=0;i<a;i++){
		cout<<ans[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3232
#include <math.h>
int i,n,x[1000],y[1000];
double t;
double Distance(int p);
main(){
    scanf("%d",&n);
    for(i=0;i<n;i++)scanf("%d",&x[i]);
    for(i=0;i<n;i++)scanf("%d",&y[i]);
    for(i=1;i<5;i++)printf("%lf\n",Distance(i));
}
double Distance(int p){
    int i;
    for(t=0,0,i=0;i<n;i++){
        if(p==4)t=t>abs(x[i]-y[i])?t:abs(x[i]-y[i]);
        else t+=pow(1.0*abs(x[i]-y[i]),p);
    }
    return p==4?t:pow(t,1.0/p);
}

Measured memory_bytes: 1984
using System;
using static System.Console;
using static System.Math;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace atcoder
{
    class Program
    {
        //メイン関数
        static void Main(string[] args)
        {
            string[] S = Read().Split('/');
            int Year = int.Parse(S[0]);
            int Month = int.Parse(S[1]);
            int Day = int.Parse(S[2]);

            if (Year < 2019 || (Year == 2019 && Month < 4) || (Year == 2019 && Month == 4 && Day <= 30)) WriteLine("Heisei");
            else WriteLine("TBD");
        }

        //メインじゃない関数
        private static string Read() { return ReadLine(); }
        private static int ReadI() { return int.Parse(ReadLine()); }
    }
}


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

using namespace std;



int main(){
	long long ans = 0;
	//	I-, O-, T-, J-, L-, S- and Z
	long long I, O, T, J, L, S, Z;
	scanf("%lld %lld %lld %lld %lld %lld %lld",&I,&O,&T,&J,&L,&S,&Z);
	if(I % 2 == J % 2 && J % 2 == L % 2 ){
		ans += (I + J + L) * 2;
	}else{
		if(min(I, min(J, L)) == 0){
			ans += (I / 2 + J / 2 + L / 2) * 4;
		}else{
			ans += (I + J + L - 1) * 2;
		}
	}

	ans += O * 2;
	printf("%lld\n",ans / 2);

	return 0;
}

Measured memory_bytes: 256
def resolve():
    # 整数 1 つ
    n = input()
    # 整数複数個
    # a, b, c = list(map(int, input().split()))
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]
    i = len(n) -2

    print(n[0] + str(i) + n[-1])


resolve()

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b)
{
   return a%b ==0 ? b : gcd(b,a%b);
}
int a[10000];
int main()
{
    int n;
    cin>>n;
    long long ans=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        ans+=a[i]-1;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int dx[]={1,0,-1,0,1,-1,-1,1};
const int dy[]={0,1,0,-1,1,1,-1,-1};
const int INF = 1e9;
const long long LINF = 1e18;
const double EPS = 1e-8;
#define pb push_back
#define mk make_pair
#define fr first
#define sc second
#define ll long long
#define reps(i,j,k) for(int i = (j); i < (k); ++i)
#define rep(i,j) reps(i,0,j)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
typedef pair<int,int> Pii;
typedef vector<int> vi;
typedef pair<string, int> Psi;
typedef pair<ll, ll> Pll;
int data[100010];
int main(){
	string str;
	cin >> str;
	int g = 0;
	int p = 0;
	int won = 0;
	int lose = 0;
	rep(i,str.size()){
		if(str[i] == 'g' && g >= p+1){
			++p;
			++won;
		}
		else if(str[i] == 'g'){
			++g;
		}
		else if(str[i] == 'p' && g >= p+1){
			++p;
		}
		else{
			++g;
			++lose;
		}
	}
	cout << won - lose << endl;

	return 0;
}

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

typedef long long ll;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define dep(i, a, n) for(int i = a; i >= (n); i--)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll n, a[10001], cnt = 0;
  cin >> n;
  rep(i, n) {
    cin >> a[i];
  }
  rep(i, n - 1) {
    if(a[i] == a[i + 1]) {
      cnt++;
      i++;
    }
  }
  cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
#define asn ans
using namespace std;
template <typename T> istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;

int main() {
	int h, w; CI h >> w;
	char s[51][51] = {};
	REP(i, h) {
		REP(j, w) {
			CI s[i][j];
		}
	}

	FOR(i, 1, h) {
		FOR(j, 1, h) {
			if (s[i][j] == '#' && s[i][j - 1] != '#' && s[i - 1][j] != '#' && s[i][j + 1] != '#' && s[i + 1][j] != '#') { CO "No" EN; return 0; }
		}
	}
	CO "Yes" EN;
}

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

int main()
{
  int N, K, S;
  cin >> N >> K >> S;
  int SS = S + 1;
  if (S + 1 > pow(10, 9))
    SS = 1;
  rep(i, K) cout << S << " ";
  rep(i, N - K) cout << SS << " ";
  cout << endl;
  return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
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;
}

ll M = 1000000007;

void solve()
{
	int n,k;
	cin>>n>>k;
	vector<int>a(n);
	rep(i,n)cin>>a[i];
	sort(all(a));
	ll ans=0;
	rep(i,k){
		ans+=a[i];
	}
	cout<<ans<<endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}


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

int main(){
  int N, X;
  cin >> N >> X;
  
  vector<int> m(N);
  cin >> m.at(0);
  int min = m.at(0);
  int min_index;
  
  for(int i = 1; i < N; i++){
    cin >> m.at(i);
    
    if(m.at(i) < min){
      min = m.at(i);
      min_index = i;
    }
  }
  
  int ssum = 0;
  for (int i = 0; i < N; i++){
    ssum += m.at(i);
  }
  
  int quo;
  quo = (X - ssum) / min;
  cout << N + quo << endl;
}



Measured memory_bytes: 256
n,m = map(int,input().split())
s = [0]*m
c = [0]*m
flag = 1
q = [''] * n
ans = ''

for i in range(m):
    s[i] , c[i] = map(int,input().split())
    
for i in range(m):
    if q[s[i]-1] == '' or q[s[i]-1] == str(c[i]):
        q[s[i]-1] = str(c[i])
    else:
        flag = 0

if q[0] == '0' and n != 1:
    flag = 0
        
for i in range(n):
    if q[i] == '':
        if i == 0:
            q[i] = 1
        else:
            q[i] = 0
    ans += str(q[i])

if n == 1 and m == 0:
    ans = '0'

if flag == 1:
    print(ans)
elif flag == 0:
    print("-1")

Measured memory_bytes: 38256
import java.io.BufferedReader
import java.io.BufferedWriter

fun main() = Case().exec(::solve)
//fun main() = TestExecutor.assert(testCase) { Case(it.r, it.w).exec(::solve) }

/** https://atcoder.jp/contests/abc178/tasks/abc178_a **/
fun solve(c: Case) {
    c.println(if (c.long() == 0L) "1" else "0")
}

class Case(
    private val input: BufferedReader = System.`in`.bufferedReader(),
    private val out: BufferedWriter = System.out.bufferedWriter()
) {
    fun exec(fn: (Case) -> Unit) = input.use { out.use { execInThread(fn) } }
    private fun execInThread(fn: (Case) -> Unit) =
        Thread(null, { fn(this) }, "solve", 64 * 1024 * 1024)
            .apply { setUncaughtExceptionHandler { _, e -> e.printStackTrace(); kotlin.system.exitProcess(1) } }
            .apply { start() }.join()

    fun println(c: CharSequence?) = out.appendln(c)
    fun string(): String = input.readLine().trimEnd()
    fun long(): Long = input.readLine().toLong()
    fun intList(): List<Int> = input.readLine().split(" ").map { it.toInt() }
    fun longList(): List<Long> = input.readLine().split(" ").map { it.toLong() }
}

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

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define pb push_back
#define mp make_pair

using namespace std;

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

int main()
{

    //ifstream cin("input.txt");
    //ofstream cout("output.txt");
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    //ios_base::sync_with_stdio(false);
    //cin.tie(0);

    int n;
    cin >> n;

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

    vector<vector<ll> > dp(n, vector<ll>(2));
    dp[0][0] = a[0] / 2;
    if (a[0]) {
        dp[0][1] = (a[0] - 1) / 2 + 1;
    }

    for (int i = 1; i < n; ++i) {
        dp[i][0] = a[i] / 2 + dp[i - 1][0];
        if (a[i]) {
            dp[i][0] = max(dp[i][0], (a[i] - 1) / 2 + dp[i - 1][1]);
            dp[i][1] = (a[i] - 1) / 2 + 1 + dp[i - 1][0];
            if (a[i] >= 2) {
                dp[i][1] = max(dp[i][1], (a[i] - 2) / 2 + 1 + dp[i - 1][1]);
            }
        }
    }
    cout << dp[n - 1][0] << "\n";

}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int i=0; i<n; i++)
#define REP2(i, a, b) for(int i=a; i<b; i++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

void inc(long long &d, long long &m, long long &dm, long long &dmc, char c){
    switch(c){
        case 'D':
            d++;
            break;
        case 'M':
            m++;
            dm += d;
            break;
        case 'C':
            dmc += dm;
            break;
    }
}
void dec(long long &d, long long &m, long long &dm, long long &dmc, char c){
    switch(c){
        case 'D':
            d--;
            dm -= m;
            break;
        case 'M':
            m--;
            break;
    }
}

long long solve(long long N, string S, long long k){
    long long d = 0;
    long long m = 0;
    long long dm = 0;
    long long dmc = 0;
    for(long long i=0; i<k; i++){
        inc(d, m, dm, dmc, S[i]);
    }
    for(long long i=k; i<N; i++){
        dec(d, m, dm, dmc, S[i-k]);
        inc(d, m, dm, dmc, S[i]);
    }
    return dmc;
}

int main(){
    long long N, Q;
    string S;
    cin >> N >> S >> Q;
    vector<long long> K(Q);
    REP(i, Q) cin >> K[i];
    REP(i, Q)
        cout << solve(N, S, K[i]) << endl;
    return 0;
}


Measured memory_bytes: 2308
#include<bits/stdc++.h>
using namespace std;
long long n,w,f[100005],a[105],b[105];
int main()
{
    cin>>n>>w;
    for(int i=1;i<=n;i++) cin>>a[i]>>b[i];
    for(int i=1;i<=n;i++)
    for(int j=w;j>=a[i];j--)
    f[j]=max(f[j],f[j-a[i]]+b[i]);
    cout<<f[w];
    return 0;
}

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

int main() {
  int N,minx=1000000,Ans=0;
  cin>>N;
  vector<int> P(N);
  rep(i,N){cin>>P.at(i);
          if(P.at(i)<=minx){minx=P.at(i);Ans++;}
          }
  cout<<Ans<<endl;
}


Measured memory_bytes: 3984
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define REP(i,e) for (int i = 0; i != int(e); i++)
#define FORIT(i, A) for (auto i : A)
#define ISEQ(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << endl
#define SZ(x) ((int)(x).size())

int main(int argc, char const *argv[])
{

	int a, b;
	while(scanf("%d %d", &a, &b) != EOF)
	{
		int sum = a+b;	
		int digit = 0;
		while(sum)
		{
			digit++;
			sum /= 10;
		} 
		printf("%d\n", digit);
	}
	return 0;
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

bool Graph[8][8];

int dfs(int v, int n, bool visited[8]) {
	bool All_Visited = true;
	for (int i = 0; i < n; i++) {
		if (visited[i] == false) {
			All_Visited = false;
		}
	}
	if (All_Visited) {
		return 1;
	}
	int ret = 0;
	for (int i = 0; i < n; i++) {
		if (Graph[v][i] == false) {
			continue;
		}
		if (visited[i]) {
			continue;
		}
		visited[i] = true;
		ret += dfs(i, n, visited);
		visited[i] = false;
	}
	return ret;
}

signed main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		Graph[a][b] = Graph[b][a] = true;
	}
	bool visited[8] = {};
	visited[0] = true;
	cout << dfs(0, n, visited) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
const long mod=998244353;
long power(long a,long b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
long dp[3030][3030];
long sum[3030][3030];
long sum2[3030][3030];
main()
{
	int A,B,C,D;
	cin>>A>>B>>C>>D;
	if(A==C||B==D)
	{
		if(A==C&&B==D)cout<<1<<endl;
		else if(A==C)cout<<power(A,D-B)<<endl;
		else cout<<power(B,C-A)<<endl;
		return 0;
	}
	dp[A][B]=1;
	sum[A][B]=1;
	for(int i=A+1;i<=C;i++)
	{
		sum[i][B]=sum[i-1][B]*B%mod;
		for(int j=B;j<=D;j++)
		{
			sum2[i-1][j]=(sum2[i-1][j-1]+sum[i-1][j])%mod*(i-1)%mod;
		}
		for(int j=B+1;j<=D;j++)
		{
			long T=0;
			T=sum2[i-1][j-1];
			/*for(int y=B;y<j;y++)
			{
				(T+=sum[i-1][y]*power(i-1,j-y)%mod)%=mod;
			}*/
			dp[i][j]=T;
			sum[i][j]=(T+sum[i-1][j]*j)%mod;
		}
		for(int j=B;j<=D;j++)(sum[i-1][j]*=j)%=mod;
	}
	long ans=0;
	for(int x=A;x<=C;x++)for(int y=B;y<=D;y++)
	{
		(ans+=dp[x][y]*power(y,C-x)%mod*power(C,D-y)%mod)%=mod;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 216448
import java.util.Scanner;
//057C
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
		long n =sc.nextLong();
		int rootN= (int) (Math.sqrt(n));
		long ans =n;
		for (int i=1;i<=rootN;i++) {
			if(n%i==0) {
				long j=n/i;
				String s=String.valueOf(Math.max(i, j));
				ans =Math.min(s.length(),ans);
			}
		}
		System.out.println(ans);
		
		//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
	}
}

Measured memory_bytes: 23764
N = gets.to_i
A = []
for i in 0..1
    A[i] = []
    A[i] = gets.strip.split.map(&:to_i)
end

answer = []

for i in 0..N-1

    answer[i] = A[0].slice(0..i).inject(:+) + A[1].slice(i..N-1).inject(:+)

end

puts answer.max


Measured memory_bytes: 1916
#include <iostream>
#include <cstdlib>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>


using namespace std;

int x[1000000] = {};
vector<int> edge[1000000] = {}; 
bool visit[1000000] = {};

void count(int i, int add){
    if(visit[i]){ return; }
    x[i] += add;
    visit[i] = true;
    for(auto child : edge[i]){
        count(child, x[i]);
    }
}

int main()
{
    int N, Q;
    cin >> N >> Q;
    for(int i = 0; i < N-1; ++i){
        int a, b;
        cin >> a >> b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    for(int i = 0; i < Q; ++i){
        int tmp, tmp2;
        cin >> tmp >> tmp2;
        x[tmp] += tmp2;
    }
    count(1, 0);
    
    for(int i = 1; i <= N; ++i){
        cout << x[i] << " ";
    }
}


Measured memory_bytes: 40704
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
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;

enum Type{
	I,
	O,
};


int main(){

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

	char* S = new char[M+1];
	char* T = new char[N+1];

	scanf("%s",S);
	scanf("%s",T);

	int*** dp = new int**[M+1];
	for(int i = 0; i <= M; i++){
		dp[i] = new int*[N+1];
		for(int k = 0; k <= N; k++){
			dp[i][k] = new int[2];
			dp[i][k][I] = 0;
			dp[i][k][O] = 0;
		}
	}

	int ans = 0;

	for(int i = 0; i <= M; i++){
		for(int k = 0; k <= N; k++){
			if(i != 0){
				if(S[i-1] == 'I'){
					dp[i][k][I] = dp[i-1][k][O]+1;
				}else if(S[i-1] == 'O' && dp[i-1][k][I] > 0){
					dp[i][k][O] = dp[i-1][k][I]+1;
				}
			}

			if(k != 0){
				if(T[k-1] == 'I'){
					dp[i][k][I] = max(dp[i][k][I],dp[i][k-1][O]+1);
				}else if(T[k-1] == 'O' && dp[i][k-1][I] > 0){
					dp[i][k][O] = max(dp[i][k][O],dp[i][k-1][I]+1);
				}
			}
			ans = max(ans,dp[i][k][I]);
		}
	}

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

	return 0;
}

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


int main() {
  int N, d[100] = {0};
  cin >> N;

  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    d[a-1]++;
  }

  int cnt = 0;
  for (int i = 0; i < 100; i++) {
    if (0 < d[i]) cnt++;
  }

  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int n,e;
	cin>>n;
	e=(n%2?n:(n+1));
	cout<<n*(n-1)/2-n/2<<endl;
	for(int i=1;i<=n;i++)for(int j=i+1;j<=n;j++)if(i+j!=e)cout<<i<<" "<<j<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
int main()
{
  ll a,b,c,k;
  cin >> a >> b >> c >> k;
  if(k%2==1)printf("%lld",b-a);
  else printf("%lld",a-b);
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<bitset>
using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 1e+8
#define EPS 1e-8
#define rep(i,j) for(int i = 0; i < (j); i++)
#define reps(i,j,k) for(int i = (j); i < (k); i++)
int main(){
	char str[12800];
	while(~scanf("%s",str)){
		int len = strlen(str);
		int joi = 0;
		int ioi = 0;
		for(int i = 0; i < len-2; i++){
			if(str[i] == 'J' && str[i+1] == 'O' && str[i+2] == 'I')joi++;
			if(str[i] == 'I' && str[i+1] == 'O' && str[i+2] == 'I')ioi++;
		}
		printf("%d\n%d\n",joi,ioi);
	}
	return 0;
}

Measured memory_bytes: 1148
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define pi 3.1415926
using namespace std;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef pair<long long,int> pli;
typedef pair<int,long long> pil;
const int INF=1000000007;
const int MOD=1000000007;
const int nmax=20123;

int n,w[nmax],s[nmax];
vector<pii> v2;
ll v[nmax],dp[nmax],res;

int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;++i){
        scanf("%d%d%lld",&w[i],&s[i],&v[i]);
        v2.pb({w[i]+s[i],i});
    }
    sort(v2.begin(),v2.end());
    for(int i=0;i<v2.size();++i){
        int pos=v2[i].second;
        for(int j=s[pos];j>=0;--j){
            if(dp[j+w[pos]]<dp[j]+v[pos])
                dp[j+w[pos]]=dp[j]+v[pos];
        }
    }
    for(int i=0;i<=20000;++i)
        if(res<dp[i])
            res=dp[i];
    printf("%lld\n",res);
    return 0;
}
//    ios::sync_with_stdio(false);
//    cin.tie(0);
//    cout.tie(0);


Measured memory_bytes: 384