akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;

/*  divisor(n)
    入力：整数 n
    出力：nのすべての約数
    計算量：O(√n)
*/
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}

using ll = long long;

int main() {
    ll N;
    cin >> N;
    ll ans = 0;

    // K で割り切れない時
    auto div = divisor(N - 1);
    ans += (int)div.size() - 1;

    // K で割り切れる時
    auto dv = divisor(N);
    for (auto k : dv) {
        if (k == N) ans++;
        if (k == 1 || k == N) continue;
        ll now = k;
        while (N % now == 0) {
            if ((N / now - 1) % k == 0) { ans++; }
            now *= k;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 384
use v5.18;
use warnings;
use utf8;
sub line { chomp(my $str = <>); $str; }
sub split_line { (split / /, line) }

my ($l1, $l2, $r1, $r2) = split_line;
my ($l, $r) = ($l1 + $l2, $r1 + $r2);
say $l > $r ? 'Left' : $l < $r ? 'Right' : 'Balanced';


Measured memory_bytes: 640
N,T = map(int,input().split())
c = 0
for _ in range(N):
  _c, _t = map(int,input().split())
  if _t <= T:
    if c == 0:
      c = _c
    elif c != 0 and _c <= c:
      c = _c
print(c if c != 0 else "TLE")

Measured memory_bytes: 3060
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

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

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;

template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H); REP(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); REP(i, n)os << v[i] << (i == n - 1 ? "" : " "); return os; }
template <class T = int> inline T IN() { T x; cin >> x; return x; }
template<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(6);*/ } } pre__;

int main() {
	int N = IN();
	vi A(N);
	REP(i, N) {
		A[i] = IN();
		A[i]--;
	}
	int L = 0;
	int ans = 0;
	REP(i, N) {
		L = A[L];
		if (L == 1) {
			OUT(ans+1);
			return 0;
		}
		ans++;
	}
	OUT("-1");
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
inline int read() {
	int x = 0, fh = 1;
	char c = getchar();
	while (c < '0' || c > '9') {
		if (c == '-') fh = -1;
		c = getchar();
	}
	while (c >= '0' && c <= '9') {
		x = (x << 1) + (x << 3) + c - '0';
		c = getchar();
	}
	return x * fh;
}
int n;
int main() {
	n = read();
	cout << (n % 10 == n / 100 ? "Yes\n" : "No\n");
	return 0;
}

Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {
	
	
	static void canMultiply(int a) {
		
		for(int i=1;i<10;i++) {
			for(int j=1;j<10;j++) {
				if(a==j*i) {
					System.out.println("Yes");
					return;
				}
			}
		}
		System.out.println("No");
		
		
	}
		public static void main(String[] args) {
			
			Scanner sc =new Scanner(System.in);
			
			
			int a,b;
			a=sc.nextInt();
			
			canMultiply(a);
			
			
		
		
		
		}

}


Measured memory_bytes: 23124
#include <iostream>
#include <map>

using namespace std;

int main()
{
    string s, x;
    cin >> s;
    int cnt = 0;
    for (int i = 0; i < s.size(); i++)
        if (s[i] < 'a')
            s[i] += 32;
    while (cin >> x)
    {
        if (x == "END_OF_TEXT")
            break;
        for (int i = 0; i < x.size(); i++)
            if (x[i] < 'a')
                x[i] += 32;
        if (s == x)
            cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

int a, b, k, num[4], ans = 0x7fffffff, cnt, nums[4];

void solve1(int a, int b) {
	cnt += b-a;
}
void solve2(int a, int b) {
	cnt += (b-a)/2;
	int res = (b-a)%2;
	if (res) cnt += 2;
}
int main(void) {
	scanf("%d%d%d", &nums[1], &nums[2], &nums[3]);
	for(int i = 1; i <= 3; ++i) num[i] = nums[i];
	sort(num+1, num+4);
	/*if (num[1] == num[2] && num[1] == num[3]) return puts("0"), 0;
	if (num[1] == num[2]) {
		solve1(num[1], num[3]);
		cout << cnt;
		return 0;
	}
	if (num[2] == num[3]) {
		solve2(num[1], num[3]); 
		cout << cnt;
		return 0;
	}
	if (num[2] - num[1] % 2 == 0) {
		cnt += (num[2] - num[1])/2;
		num[1] = num[2];
		solve1(num[1], num[3]);
		// ans = min(ans, cnt);
	}
	else {
		cnt += (num[2] - num[1]) / 2;
		num[2]++, num[1] = num[2]; cnt += 2; num[3]++;
		// ans = min(ans, cnt);
	}
	sort(num+1, num+4);
	if (num[1] == num[2]) {
		solve1(num[1], num[3]);
		ans = min(ans, cnt);
		// return 0;
	}
	if (num[2] == num[3]) {
		solve2(num[1], num[3]); 
		ans = min(ans, cnt);
		// return 0;
	}
	cnt = 0;
	for(int i = 1; i <= 3; ++i) num[i] = nums[i];
	cnt += num[3] - num[2];
	num[1] += num[3] - num[2];
	num[2] = num[3];
	solve2(num[1], num[3]);
	ans = min(cnt, ans);
	cout << ans;*/
	int res = num[3] - num[2] + num[3] - num[1];
	if (res % 2 == 0) printf("%d", res/2);
	else {//2 3 6 3 + 4 21 - 6 - 3 - 2
		res = (num[3]+1)*3-num[3]-num[2]-num[1];
		printf("%d", res/2);
	}
	return 0;
}

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

#define REP(i,n) for(int i=0; i<n; ++i)
#define IREP(it,array) for(vector<int>::iterator it=array.begin(); it!=array.end(); ++it)
#define PREP(it,array) for(vector<P>::iterator it=array.begin(); it!=array.end(); ++it)
#define SREP(it,array) for(vector<string>::iterator it=array.begin(); it!=array.end(); ++it)

#define MP       make_pair
#define PB       push_back
#define ALL(x)   (x).begin(),(x).end()

const int INF = 1<<29;
const double EPS = 1e-9;
double zero(double d){
  return d < EPS ? 0.0 : d;
}

typedef long long LL;
typedef pair<int,int> P;

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

struct Sta{
  int ax,ay;
  int bx,by;
  int count;
};

int main()
{
  cout.setf(ios::fixed, ios::floatfield);
  cout.precision(7);

  int X,Y;
  while( cin>>X>>Y, X ){
    int tx,ty;
    cin >>tx>>ty;

    int kx,ky;
    cin>>kx>>ky;

    bool dep[Y+1][X+1];
    REP(i,Y){
      REP(j,X){
	int ttt;
	cin >> ttt;
	dep[i+1][j+1] = ttt;
      }
    }

    bool used[X+1][Y+1][X+1][Y+1];
    memset( used, 0, sizeof(used) );

    queue<Sta> que;
    Sta s;
    s.ax = tx;
    s.ay = ty;
    s.bx = kx;
    s.by = ky;
    s.count = 0;
    que.push(s);

    int res=101;
    while( ! que.empty() ){
      Sta t = que.front(); que.pop();
      if( t.ax == t.bx && t.ay == t.by ){
	res = min(res,t.count);
	break;
      }

      if( t.count >= 100 ){
	break;
      }
	
      REP(i,4){
	Sta t2 = t;
	t2.count++;

	int nAx = t2.ax + dx[i];
	int nAy = t2.ay + dy[i];
	int nBx = t2.bx + dx[(i+2)%4];
	int nBy = t2.by + dy[(i+2)%4];
	if( 0<nAx && nAx <= X && 0<nAy && nAy<=Y ){
	  if( ! dep[nAy][nAx] ){
	    t2.ax = nAx;
	    t2.ay = nAy;
	  }
	}
	if( 0<nBx && nBx <= X && 0<nBy && nBy<=Y ){
	  if( ! dep[nBy][nBx] ){
	    t2.bx = nBx;
	    t2.by = nBy;
	  }
	}

	if( ! used[t2.ax][t2.ay][t2.bx][t2.by] ){
	  used[t2.ax][t2.ay][t2.bx][t2.by] = true;
	  que.push(t2);
	}
      }
    }

    if(res==101)
      cout << "NA" << endl;
    else
      cout << res << endl;
  }

  return 0;
}

Measured memory_bytes: 7960
from collections import defaultdict

N,M=map(int,input().split())
A=list(map(int,input().split()))
B=[0]*(N+1)
C=defaultdict(int)
C[0]+=1
for i in range(N):
    B[i+1]=(B[i]+A[i])%M
    C[B[i+1]]+=1
ans=0
for i in C.values():
    ans+=i*(i-1)//2
print(ans)


Measured memory_bytes: 15084
n = int(input())
sum = []
for i in range(1, n + 1):
  s = 0
  if (i % 2 == 0):
    continue
  for j in range(1, i + 1):
    if (i % j == 0):
      s += 1
  sum.append(s)

print(sum.count(8))


Measured memory_bytes: 2940
#include <stdio.h>
#define NIL -1

typedef struct {
  int id;
  int l;
  int r;
  int p;
} Tree;

Tree tree[30];
int max = 0;
int H[30];
void init(int n){
  for(int i = 0; i < n; ++i){
    tree[i].id = NIL;
    tree[i].l= NIL;
    tree[i].r = NIL;
    tree[i].p = NIL;
  }
}
void print_sibling(int i){
  printf("sibling = ");
  int p = tree[i].p;
  if(p == NIL)
    printf("%d", NIL);
  else if(tree[p].l == NIL || tree[p].r == NIL)
    printf("%d", NIL);
  else if(i == tree[p].l)
    printf("%d", tree[p].r);
  else
    printf("%d", tree[p].l);
  printf(", ");
}
void print_degree(int i){
  int count = 0;
  if(tree[i].l != NIL)
    ++count;
  if(tree[i].r != NIL)
    ++count;
  printf("degree = %d, ", count);
}
void print_depth(int i){
  int count = 0;
  while(1){
    i = tree[i].p;
    if(i == NIL)
      break;
    ++count;
  }
  printf("depth = %d, ", count);

}
int getRoot(int n){
  int root = 0;
  for(int i = 0; i < n; ++i){
    if(tree[i].p == NIL){
      root = i;
      break;
    }
  }
  return root;
}

int setHeight(int n){
  int h1 = 0, h2 = 0;
  if(tree[n].r != NIL)
    h1 = setHeight(tree[n].r) + 1;
  if(tree[n].l != NIL)
    h2 = setHeight(tree[n].l) + 1;
  H[n] =(h1 > h2 ? h1 : h2); 
  return (h1 > h2 ? h1 : h2);
}
void print(int n){
  for(int i = 0; i < n; ++i){
    printf("node %d: parent = %d, ", tree[i].id, tree[i].p);
    print_sibling(i);
    print_degree(i);
    print_depth(i);
    printf("height = %d, ", H[i]);
    if(tree[i].p == NIL)
      printf("root");
    else if(tree[i].r == NIL && tree[i].l == NIL)
      printf("leaf");
    else
      printf("internal node");
    printf("\n");
  }
}

int main(){
  int n, id, l, r;
  
  scanf("%d", &n);
  init(n);
  for(int i = 0; i < n; ++i){
    scanf("%d%d%d", &id, &l, &r);
    tree[id].id = id;
    tree[id].l = l;
    tree[id].r = r;
    if(l != NIL)
      tree[l].p = id;
    if(r != NIL)
      tree[r].p = id;
  }
  setHeight(getRoot(n));
  print(n);
  return 0;
}



Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INT_INF = 2147483647;
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 (b<a) { a=b; return 1; } return 0; }
typedef pair<int,int> P;

vector<int> to[100005];
vector<bool> d(100005);
vector<bool> visited(100005,0);
bool flag = 1;
void dfs(int v, int p=-1) {
  for (auto u : to[v]) {
    //if (u == p) continue;
    if(visited[u]){
      if(d[u]==d[v])flag=0;
      continue;
    }
    visited[u]=1;
    d[u] = 1-d[v];
    dfs(u,v);
  }
}

int main() {
  ll n,m;
  cin >> n >> m;
  rep(i,m) {
    int u,v;
    cin >> u >> v;
    --u; --v;
    to[u].push_back(v);
    to[v].push_back(u);
  }
  d[0]=0;
  //flag=1;
  visited[0]=1;
  dfs(0);
  if(flag){
    ll c0 =0,c1=0;
    rep(i,n){
      if(d[i]==0)c0++;
      else c1++;
    }
    ll ans = c0*c1-m;
    cout << ans << endl;
  }else{
    ll ans= n*(n-1)/2LL - m;
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 7040
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 2000; int s;
const lli mod = 1e9 + 7;

lli memo[maxN];
lli solve(int sum = 0)
{
  if (sum > s) return false;
  if (sum == s) return true;
  if (memo[sum] != -1) return memo[sum];

  lli ans = 0;
  for (int i = 3; i <= s; i++)
    ans = (ans + solve(sum + i)) % mod;
  return memo[sum] = ans;
}

int main()
{
  while (scanf("%d", &s) != EOF)
  {
    memset(memo, -1, sizeof(memo));
    lli ans = solve();
    printf("%lld\n", ans);
  }
  return 0;
}

Measured memory_bytes: 3832
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))


N=int(input())

print(1000-(N%1000) if N%1000>0 else 0)


Measured memory_bytes: 10460
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<cmath>
#include<sstream>
#include<iomanip>
#include <map>
#include <stack>

struct max_min
{
    int64_t max = 0;
    int64_t min = 0;
};

const int64_t cc = pow( 10, 9 ) + 7;
//std::cout<< std::fixed << std::setprecision(10) << ( double )( max ) / 2;
bool sort_pair( std::pair< int64_t, int64_t > origin, std::pair< int64_t, int64_t > another )
{
    return origin.first < another.first;
}

int main()
{
    std::string word;
    std::string w = "Yes";
    int64_t a,b,c,d,e,f;
    std::cin>> a;

    c = ( a / 500 ) * 1000 ;
    b = a % 500;
    c += ( b / 5 ) * 5;

    std::cout<< c;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a,b,i;
    int num;
    scanf("%d%d",&a,&b);
    num=a*4;
    for(i=0;i<a;i++){
        if(num==b) break;
        num-=2;
    }
    if(num==b) printf("Yes\n");
    else printf("No\n");

    return 0;
}

Measured memory_bytes: 1636
N = int(input())
alp_list = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
ans = ''

for i in range(1,99):
  if N <= 26 ** i:
    N -= 1
    for j in range(i):
      ans += alp_list[N % 26]
      N  = N // 26
    break
  else:
    N -= 26 ** i
print(ans[::-1]) 

Measured memory_bytes: 9192
#include<bits/stdc++.h>
#define ULTRA 2134567890
using namespace std;

int h[100007] = {};
int dp[100007] = {};

int main() {
	
	int i,j;
	int N,k;
	
	cin >> N >> k;
	for( i=1; i<=N; i++) {
		cin >> h[i];
		dp[i] = ULTRA;
	}
	dp[1] = 0;
	for( i=1; i<=N; i++) {
		for( j=1; j<=k && i+j <= N; j++) {
			dp[i+j] = min( dp[i] + abs( h[i]-h[i+j]), dp[i+j]);
		}
	}
	cout << dp[N] << "\n";
	
	return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

vector<ll> makeDivisors(ll n) {
    vector<ll> ret;
    for(ll i = 1; i * i <= n; i++) {
        if(n%i == 0) {
            ret.push_back(i);
            if(i*i != n) ret.push_back(n/i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}

ll cal(ll a, ll b) {
    return pow(a, 5LL) - pow(b, 5LL);
}

int main() {
    // (A - B) (A^4 + A^3 B + A^2 B^2 + A B^3 + B^4)
    // どちらかはプラスなのでAをプラスとする
    ll X;
    cin >> X;
    vector<ll> divs = makeDivisors(X);
    for (ll a = 0; a < 100000; a++) {
        for (ll d : divs) {
            ll b = a - d;
            if (cal(a, b) == X) {
                printf("%ld %ld\n", a, b);
                return 0;
            }
        }
    }
}

Measured memory_bytes: 4308
#include <iostream>
#include <stdio.h>
#include <ctype.h>

using namespace std;

int main()
{
	char a[11] = {0};
	char b[11] = {0};
	char c[11] = {0};
	
	cin >> a >> b >> c;

	a[0] = (toupper(a[0]));
	b[0] = (toupper(b[0]));
	c[0] = (toupper(c[0]));
	cout << a[0] << b[0] << c[0] << "\n";
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    while(N){
        int flag = 0,used = 0,cnt = 0;//下についている := 0 左足2,右足1
        rep(i,0,N){
            string s;
            cin >> s;
            if(!flag){
                if(s == "lu")used += 2;
                if(s == "ru")used += 1;
                if(s == "ld")used -= 2;
                if(s == "rd")used -= 1;
            }else{
                if(s == "ld")used += 2;
                if(s == "rd")used += 1;
                if(s == "lu")used -= 2;
                if(s == "ru")used -= 1;
            }
            if(used == 3){
                used = 0;
                flag = !flag;
                cnt++;
            }
        }
        cout << cnt << endl;
        cin >> N;
    }
}


Measured memory_bytes: 2992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype(i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype(i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,mod=1000000007;
const double pi=3.1415926535897932,eps=1e-6;
ll h,w;
int main()
{
    fastio;
    cin>>h;
    while(h) w++,h>>=1;
    h=1;while(w) h<<=1,w--;
    cout<<h-1;
    return 0;
}

Measured memory_bytes: 384
// https://qiita.com/e869120/items/eb50fdaece12be418faa

#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

struct UnionFind {
    vector<int> par;
    UnionFind(int n) : par(n, -1) {}

    void init(int n) {
        par.assign(n,-1);
    }

    int root(int x) {
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }

    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int size(int x) {
        return -par[root(x)];
    }
};

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

    UnionFind tree(n);

    int a[m], b[m];
    rep(i, m) {
        cin >> a[i] >> b[i];
        --a[i], --b[i];
    }

    int res = 0;
    rep(i, m) {
        tree.init(n);
        rep(j, m) {
            if (i == j) continue;
            tree.unite(a[j], b[j]);
        }

        int c = 0;
        rep(j, n) {
            if (tree.par[j] < 0) ++c;
        }
        if (1 < c) ++res;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

/**
 * https://abc063.contest.atcoder.jp/tasks/arc075_a
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[N];
		int sum = 0;
		for(int i=0; i<N; i++){
			a[i] = sc.nextInt();
			sum += a[i];
		}
		sc.close();
		
		int ans = sum;
		
		if(ans%10==0){
			Arrays.sort(a);
			int n = -1;	
			for(int i=0; i<N; i++){
				if(a[i]%10!=0){
					n = a[i];
					break;
				}
			}
			ans = n==-1 ? 0 : ans-n;
		}
			
		System.out.println(ans);

	}

}

Measured memory_bytes: 21844
import sys


H, W, M = map(int, input().split())
bomb =[]
for I in range(M):
    bom = tuple(map(lambda x: int(x) - 1, input().split()))
    bomb.append(bom)
X = [0] * H  # X:各行の爆破対象の個数
Y = [0] * W  # Y:各列の爆破対象の個数
for h, w in bomb:
    X[h] += 1
    Y[w] += 1
maxX = max(X)
maxY = max(Y)

R = [h for h, x in enumerate(X) if x == maxX]  # R:爆破対象の数が最大となる行の番号
C = [w for w, y in enumerate(Y) if y == maxY]  # C:爆破対象の数が最大となる列の番号

bomb = set(bomb)
for r in R:
    for c in C:
        if (r, c) not in bomb:
            # (r, c)に爆破対象が存在しないとき, maxX + maxY が答えとなることが確定するため, 
            # 即座に探索を終了する. これによりループの回数は最大でもM+1回となる.
            print(maxX + maxY)
            exit()
print(maxX + maxY - 1)

Measured memory_bytes: 173964
#!/usr/bin/ruby
#encoding: utf-8

n = gets.to_i
h = Hash.new(0)

(0..n-1).each do |i|
  s = gets.chomp.split("")
  s2 = s.sort.join
  h[s2] += 1
end

ans = 0

h.each do |key,value|
  ans += value * (value-1)/2
end

puts ans

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

int main(){
    int n;
    cin >> n;
    if(n<10){
        if(n==3){
            cout << "bon" << endl;
        }
        else if(n==0 || n==1 || n==6 || n==8){
            cout << "pon" << endl;
        }
        else{
            cout << "hon" << endl;
        }
    }
    else if(n<100){
        if(n%10==3){
            cout << "bon" << endl;
        }
        else if(n%10==0 || n%10==1 || n%10==6 || n%10==8){
            cout << "pon" << endl;
        }
        else{
            cout << "hon" << endl;
        }
    }
    else{
        if(n%10==3){
            cout << "bon" << endl;
        }
        else if(n%10==0 || n%10==1 || n%10==6 || n%10==8){
            cout << "pon" << endl;
        }
        else{
            cout << "hon" << endl;
        }
    }
}

Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#define rep(i,s,t) for(register int i=s;i<=t;++i)
#define _rep(i,s,t) for(register int i=s;i>=t;--i)
using namespace std;
const int N=23333;
int p;
int f[N],a[N],b[N],inv[N],c[N];
inline int fp(int a,int b){
	int res=1;
	for(;b;b>>=1,a=1ll*a*a%p)
		if(b&1)
			res=1ll*res*a%p;
	return res;
}
inline void div(int x){
	int xi=1;
	rep(i,0,p-1)
		if(x!=i)
			xi=1ll*xi*(x-i)%p;
	xi=fp(xi,p-2);
	rep(j,0,p)
		b[j]=a[j];
	_rep(j,p,1){
		int o=b[j];
		c[j-1]=(c[j-1]+xi*o)%p;
		b[j-1]=(b[j-1]+o*x)%p;
	}
}
int main(){
	scanf("%d",&p);
	rep(i,0,p-1)scanf("%d",f+i);
	inv[1]=1;
	rep(i,2,p-1)inv[i]=p-1ll*p/i*inv[p%i]%p;
	a[0]=1;
	rep(i,0,p-1)
		_rep(j,p,0)
			a[j]=(-i*a[j]+(j?a[j-1]:0))%p;
	rep(i,0,p-1)
		if(f[i])
			div(i);
	rep(i,0,p-1)
		printf("%d ",(p+c[i])%p);
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[5][4][11]={};
    int b,f,r,v;
    for(int i=0;i<n;i++){
       cin>>b>>f>>r>>v;
       a[b][f][r]+=v;
    }
    for(int j=1;j<4;j++){
       for(int k=1;k<4;k++){
          for(int l=1;l<11;l++){
             cout<<" "<<a[j][k][l];
          }
          cout<<endl;
       }
       cout<<"####################"<<endl;
    }
    for(int k=1;k<4;k++){
          for(int l=1;l<11;l++){
             cout<<" "<<a[4][k][l];
          }
          cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;

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

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

using namespace std;

struct Point {
    int x, y, color;
    bool inline operator < (const Point &rhs) const {
        return x < rhs.x;
    }
};

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

    vector<Point> p(2*n);
    for(int i = 0; i < 2*n; ++i) {
        scanf("%d%d", &p[i].x, &p[i].y);
        p[i].color = (i < n) ? 1 : 2;
    }

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

    int ans = 0;

    set<int> s;
    for(int i = 0; i < 2*n; ++i) {
        if (p[i].color == 1)
            s.insert(p[i].y);
        else {
            auto it = s.upper_bound(p[i].y);
            if (it == s.begin())
                continue;
            s.erase(prev(it));
            ++ans;
        }
    }

    printf("%d", ans);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  ll n;
  cin >>n;
  ll t[n+1],x[n+1],y[n+1];
  t[0]=0;x[0]=0;y[0]=0;
  for(ll i=1;i<n+1;i++) cin >>t[i]>>x[i]>>y[i];
  for(ll i=0;i<n;i++){
    ll dx=abs(x[i]-x[i+1]),dy=abs(y[i]-y[i+1]);
    ll dt=t[i+1]-t[i];
    if(dx+dy>dt){
      cout <<"No"<<endl;
      return 0;
    }
    if((dt-(dx+dy))%2!=0){
      cout <<"No"<<endl;
      return 0;
    }
  }
  cout <<"Yes"<<endl;
  return 0;
  }


Measured memory_bytes: 2560
#include <stdio.h>
#include <cstdio>
int main(){
	int i[10000],j,m,x[10000];
	j=0;
	do {
		scanf("%d %d",&i[j],&x[j]);
		j++;
	}while ((i[j-1]!=0) || (x[j-1]!=0));
	
	for(m=1;m<=j-1;m++){
		if(x[m-1]<i[m-1]||x[m-1]==i[m-1]){
			printf("%d %d\n",x[m-1],i[m-1]);
		}else if(x[m-1]>i[m-1]){
			printf("%d %d\n",i[m-1],x[m-1]);
		}
	}
	return 0;
}


Measured memory_bytes: 2628
#include <bits/stdc++.h>
#include "unistd.h"
using namespace std;
#define WA cout<<"char134217728";exit(0)
#define RE throw
#define TLE sleep(1000)
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end());
#define bit(n) (1<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int n, a, b;
bool z[17];
stringstream s;
void rec(int d, bool p){
  if(d==n){
    s << ' ' << a;
    return;
  }
  int i=0;
  while(z[i] || p&&(((a^b)&bit(i))==0)) i++;
  z[i] = true;
  rec(d+1, false);
  a ^= bit(i);
  rec(d+1, p);
  z[i] = false;
}
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> a >> b;
  if(__builtin_parity(b^a)){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
    return 0;
  }
  rec(0, true);
  cout << s.str().substr(1) << endl;
}

Measured memory_bytes: 3588
#include <stdio.h>

void Do(int W, int H, int x, int y){
  int c;
  double Mx, My;
  Mx = W * 0.5;
  My = H * 0.5;
  if(Mx == x && My == y) c = 1;
  else c = 0;
  printf("%f %d\n", W * 0.5 * H, c);
}

int main(void){
  int W, H, x, y;
  scanf("%d %d %d %d", &W, &H, &x, &y);
  Do(W, H, x, y);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define y0 yy
#define y1 Yy
#define yn YY
#include <assert.h>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
    int q,h,s,d,n;
    long long res=0;
    scanf("%d %d %d %d %d",&q,&h,&s,&d,&n);
    q*=4;h*=2;s=min(s,min(q,h));
    if(s*2>d){
        res+=static_cast<long long>(n/2)*d;
        n%=2;
    }
    res+=static_cast<long long>(n)*s;
    printf("%lld\n",res);
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
static const int NMAX=105;
static const int WMAX=10005;
static const int DIAGONAL=1;
static const int TOP=0;
using namespace std;
struct Item{
    int value,weight;
};
int N,W;
Item items[NMAX+1];
int C[NMAX+1][WMAX+1],G[NMAX+1][WMAX+1];

void compute(int &maxValue,vector<int> &selection){
    for(int w=0;w<=W;w++){
        C[0][w]=0;
        G[0][w]=DIAGONAL;
    }
    for(int i=1;i<=N;i++)C[i][0]=0;
    for(int i=1;i<=N;i++){
        for(int w=1;w<=W;w++){
            C[i][w]=C[i-1][w];
            G[i][w]=TOP;
            if(items[i].weight>w)continue;
            if(items[i].value+C[i-1][w-items[i].weight]>C[i-1][w]){
                C[i][w]=items[i].value+C[i-1][w-items[i].weight];
                G[i][w]=DIAGONAL;
            }
        }
    }
    maxValue=C[N][W];
    selection.clear();
    for(int i=N,w=W;i>=1;i--){
        if(G[i][w]==DIAGONAL){
            selection.push_back(i);
            w-=items[i].value;
        }
    }
    reverse(selection.begin(),selection.end());

}
int main(){
    int maxValue;
    vector<int> selection;
    cin>>N>>W;
    for(int i=1;i<=N;i++)
        cin>>items[i].value>>items[i].weight;
    compute(maxValue,selection);
    cout<<maxValue<<"\n";
    return 0;
}



Measured memory_bytes: 11044
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>



using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef pair<int,int>P;
#define INF 1000000000
 
struct edge { 
	int from, to; 
	edge (int from, int to){
		this->from=from; this->to=to;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;

int go(ll n) {
	int cnt = 0;
	while (n > 0) {
		n /= 10;
		cnt++;
	}
	return cnt;
}

int main(){
	ll n;
	cin >> n;
	int ans = 1000;
	for (ll i = 1; i*i <= n; i++) {
		if (n%i == 0) {
			ans = min(ans, go(n / i));
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main()
{
	int n;
	cin >> n;
	vector<long long> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());

	long long p = 1;
	for (int i = 0; i < n; i++) {
		if ((p != 0) && (a[i] > (long long)pow(10, 18) / p)) {
			p = -1;
			break;
		}
		p *= a[i];
	}
	cout << p << endl;
	return 0;
}

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

namespace Painting_problem
{
    class Program
    {
        static int height = 0;
        static int width = 0;
        static int[,] datas = new int[51, 51];
        static void Main(string[] args)
        {
            String input = Console.ReadLine();
            try
            {
                height = Int32.Parse(input.Split(' ')[0]);
                width = Int32.Parse(input.Split(' ')[1]);
            
                for (int i = 0; i < height; i++)
                {
                    input = Console.ReadLine();
                    for (int j = 0; j < width; j++)
                    {
                        if (input[j].Equals('#'))
                        {
                            datas[i, j] = 1;
                        }
                    }
                }
            }
            catch (Exception)
            {
                Console.WriteLine("形式エラー");
                Console.ReadLine();
                return;
            }
            bool result = true;
            //Paint
            for (int i = 0; i < height; i++)
            {
                for (int j = 0; j < width; j++)
                {
                    PaintOut(i, j);
                }
            }
            //Check Result
            for (int i = 0; i < height; i++)
            {
                for (int j = 0; j < width; j++)
                {
                    if (datas[i,j] == 1)
                    {
                        result = false;
                        break;
                    }
                }
            }
            Console.WriteLine(result ? "Yes" : "No");
            Console.ReadLine();
        }

        static void PaintOut(int x, int y)
        {
            if (datas[x,y] == 1)
            {
                bool isSuccess = false;
                if (x > 0)
                {
                    isSuccess = isSuccess || datas[x - 1, y] != 0;
                }
                if (y > 0)
                {
                    isSuccess = isSuccess || datas[x, y - 1] != 0;
                }
                isSuccess = isSuccess || datas[x + 1, y] != 0;
                isSuccess = isSuccess || datas[x, y + 1] != 0;
                if (isSuccess)
                {
                    datas[x, y] = 2;
                }
            }
        }
    }
}


Measured memory_bytes: 13268
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var h = cin.nextInt();
            var w = cin.nextInt();

            for (int i = 0; i < w + 2; i++) Console.Write("#");
            Console.WriteLine();
            for (int i = 0; i < h; i++)
            {
                var s = cin.next();
                Console.Write("#");
                Console.Write(s);
                Console.Write("#");
                Console.WriteLine();
            }
            for (int i = 0; i < w + 2; i++) Console.Write("#");
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long double a, b, v, w, t;
  cin >> a >> v >> b >> w >> t;
  if (v <= w) {
    cout << "NO\n";
    return 0;
  }
  if (a < b) {
    if (v > w) {
      if (b - a <= t * (v - w)) {
        cout << "YES\n";
      } else {
        cout << "NO\n";
      }
    } else {
      if (b - a >= t * (v - w)) {
        cout << "YES\n";
      } else {
        cout << "NO\n";
      }
    }
  } else {
    if (v > w) {
      if (a - b <= t * (v - w)) {
        cout << "YES\n";
      } else {
        cout << "NO\n";
      }
    } else {
      if (a - b >= t * (v - w)) {
        cout << "YES\n";
      } else {
        cout << "NO\n";
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3740
/*+lmake
 * STD = c++14
 * DEFINE += WAAUTOMATON
 */
#include <bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;

#ifdef WAAUTOMATON
#define debug(args...)                                                                             \
    {                                                                                              \
        dbg, args;                                                                                 \
        cerr << endl;                                                                              \
    }
#define massert(x) assert(x)
#else
#define debug(args...) // Just strip off all debug tokens
#define massert(x)
#endif

struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;
map<ULL,pair<ULL,int>> x;
int p[10000],pcnt;
void init()
{
	for(int i=2; i<=2155; ++i) {
		bool flag=true;
		for(int j=1; j<=pcnt; ++j) {
			if (i%p[j]==0) {
				flag=false;
				break;
			}
		}
		if (flag) {
			p[++pcnt]=i;
		}
	}
}
ULL getHash(int* f,int* ff,int fcnt)
{
	ULL ans=0;
	for(int i=1; i<=fcnt; ++i) {
		ans+=f[i];
		ans*=1007;
		ans+=ff[i];
		ans*=1007;
	}
	return ans;
}
void solve(long long N, vector<long long> s){
	init();
	debug(pcnt);
	int ans=0;
	bool flag=false;
	for(auto i:s) {
		LL bak=i;
		static int f[100],ff[100];
		int fcnt=0;
		for(int j=1; j<=pcnt; ++j) {
			if (i%p[j]==0) {
				f[++fcnt]=j;
				int cnt=0;
				while(i%p[j]==0) {
					++cnt;
					i/=p[j];
				}
				ff[fcnt]=cnt%3;
				if (ff[fcnt]==0) --fcnt;
			}
		}
		if (i>1) {
			LL t=sqrtl(i);
			if (t*t==i) {
				f[++fcnt]=t;
				ff[fcnt]=2;
			} else if ((t+1)*(t+1)==i) {
				f[++fcnt]=t+1;
				ff[fcnt]=2;
			} else if ((t-1)*(t-1)==i) {
				f[++fcnt]=t-1;
				ff[fcnt]=2;
			}else {
				f[++fcnt]=i;
				ff[fcnt]=1;
			}
		}
		bool flag2=true;
		for(int j=1; j<=fcnt; ++j) {
			if (ff[j]>0) {
				flag2=false;
				break;
			}
		}
		if (flag2) {
			flag=true;
			continue;
		}
		ULL hnow=getHash(f,ff,fcnt);
		for(int j=1; j<=fcnt; ++j) {
			massert(ff[j]>0);
			ff[j]=3-ff[j];
		}
		ULL to=getHash(f,ff,fcnt);
		//debug(bak,hnow,to);
		if (x.count(hnow)==0) {
			x[hnow]=make_pair(to,1);	
		} else {
			if (x[hnow].first!=to) {
				debug(hnow,x[hnow].first,to);
			}
			massert(x[hnow].first==to);
			x[hnow].second++;
		}
	} 
	int cnt=0;
	for(auto i:x) {
		cnt+=i.second.second;
	}
	debug(cnt);
	int ans2=0;
	for(auto i:x) {
		ULL a=i.first,b=i.second.first;
		int cnt=i.second.second;
		if (x.count(b)==0) {
			ans+=cnt;
		} else if (x[b].second<cnt) {
			ans+=cnt;
			//x.erase(b);
			//debug(a,b);
		} else if (x[b].second==cnt){
			ans2+=cnt;

		}
	}
	if (flag) ++ans;
	ans+=ans2/2;
	cout<<ans<<endl;
}

int main(){	
#ifdef WAAUTOMATON
	freopen("in.txt","r",stdin);
#endif
	long long N;
	scanf("%lld",&N);
	vector<long long> s(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&s[i]);
	}
	solve(N, s);
	return 0;
}



Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;}
using ll = long long;

int n,m,k,ans=1;
string s,t,u;
bool ok=true;

int main() {
  cin >> s;
  t=s; reverse(all(t));
  if(t!=s) ok=false;
  n=s.size(), m=(n-1)/2;
  t=s.substr(0,m), u=t; reverse(all(u));
  if(t!=u) ok=false;
  t=s.substr((n+3)/2-1), u=t; reverse(all(u));
  if(t!=u) ok=false;
  cout << (ok ? "Yes" : "No") << endl;
}

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

int c[110][110];

int main(){
	int h,w;
	cin>>h>>w;
	int n;
	cin>>n;
	vector<int>a(n);
	for(int i=0;i<n;i++){cin>>a[i];}
	int tmp=1;
	bool ok=true;
	for(int i=0;i<h;i++){
		if(i%2) ok=false;
                else ok=true;
		for(int j=0;j<w;j++){
			if(ok){
				if(a[tmp-1]){
					c[i][j]=tmp;
					a[tmp-1]--;
				}else{
					tmp++;
					c[i][j]=tmp;
					a[tmp-1]--;
				}
			}
			else{
				if(a[tmp-1]){
					c[i][w-1-j]=tmp;
                                        a[tmp-1]--;
                                }else{
                                        tmp++;
					c[i][w-1-j]=tmp;
                                        a[tmp-1]--;
                                }

			}
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cout<<c[i][j]<<" ";
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long 
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()

using namespace std;

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

    string s;
    cin >> s;

    int n = s.size();
    bool ok = true;

    rep(i,n){
        if(i%2==0){
            if(s[i]!='R'&&s[i]!='U'&&s[i]!='D') ok = false;
        }
        if(i%2==1){
            if(s[i]!='L'&&s[i]!='U'&&s[i]!='D') ok = false; 
        }
    }
    cout << ( ok ? "Yes" : "No" ) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
string s;
int main(){
	cin >> s;
	cout << s[0] << s[1] << s[2];
	return 0;
}

Measured memory_bytes: 3588
n, m = map(int, input().split())
a = list(map(int, input().split()))
wa = sum(a)
limit = wa * 1 /(4 * m)
cnt = 0
for i in a:
    if i >= limit:
        cnt += 1
if cnt >= m:
    print("Yes")
else:
    print("No")

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

typedef struct{
  int v;
  int w;
}baggage;


vector<baggage> vec;
int N,W,dp[1000][10000];


int rec(int i,int margin_w){
  int tmp_w;
  if(dp[i][margin_w]!=-1){
    return dp[i][margin_w];
  }
  
  tmp_w = margin_w - vec[i].w;

  if(i+1 >= N){
    dp[i][margin_w] = tmp_w < 0 ? 0 : vec[i].v;
    return dp[i][margin_w];
  }
  
  if(tmp_w < 0){
    dp[i][margin_w] =rec(i+1,margin_w); 
    return dp[i][margin_w];
  }

  dp[i][margin_w] =  max(rec(i+1,margin_w),rec(i+1,tmp_w) + vec[i].v);
  return dp[i][margin_w];
}
 

int main(){
  int input_w,input_v;
  
  baggage input;

  cin >> N >> W;

  for(int i=0;i<N;i++){
    cin >> input_v >> input_w;
    input.v = input_v;
    input.w = input_w;
    vec.push_back(input);
  }

  for(int i=0;i<N+1;i++){
    for(int j=0;j<W+1;j++){
      dp[i][j]  = -1;
    }
  }

  cout << rec(0,W) << endl;
  return 0;
}
  



Measured memory_bytes: 7104
s= input()
t =  input()
n =  len(s)
n1 = len(t)
ans= 100000
for i in range(n-n1+1):
    count= 0
    for j in range(n1):
        #print(i,j,n,n1)
        if s[i+j]==t[j]:
            continue
        else:
            count+=1
    #print(count)
    ans = min(ans,count)
print(ans)
    

Measured memory_bytes: 9040
//This Code was made by Chinese_zjc_.
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<bitset>
#include<cmath>
#include<queue>
#include<stack>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<map>
#include<set>
#include<time.h>
// #include<windows.h>
#define int long long
#define PI 3.14159265358979323
#define INF 0x3fffffffffffffff
using namespace std;
int n,m,x,dfn[100005],tim,ans;
signed main()
{
    ios::sync_with_stdio(false);
    cin>>n>>x>>m;
    for(int i=1;i<=n;++i)
    {
        if(!dfn[x])
        {
            dfn[x]=++tim;
            ans+=x;
        }
        else
        {
            int sum=0,len=tim-dfn[x]+1,now=x;
            do
            {
                now=now*now%m;
                sum+=now;
            }
            while(now!=x);
            int Left=n-tim;
            ans+=(Left/len)*sum;
            Left%=len;
            while(Left--)
            {
                ans+=x;
                x=x*x%m;
            }
            break;
        }
        x=x*x%m;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4356
//
//  header_useful.h
//  c++_acm
//
//  Created by 李弘辰 on 2019/7/23.
//  Copyright  2019 李弘辰. All rights reserved.
//

#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <list>
#include <set>
#include <unordered_set>
#include <utility> // pair
#include <map>
#include <unordered_map>
#include <iostream>
#include <sstream>
#include <algorithm> // sort
#include <string>
#include <stack>
#include <queue>
#include <fstream>
#include <bitset>


using namespace std;

#define ll long long
#define lll __int128
#define uchar unsigned char
#define ushort unsigned short
#define uint unsigned int
#define ulong unsigned long
#define ull unsigned long long

#define INT_INF 0x7fffffff

#define pi acos(-1)

#define mx(a,b) (a) > (b) ? (a) : (b)
#define mn(a,b) (a) < (b) ? (a) : (b)
#define mem(a,b) memset(a,b,sizeof(a))
#define fre(a) freopen(a,"r",stdin)

#define cio ios::sync_with_stdio(false); // Do not use it with "scanf" and other c input!
#define pb push_back
#define rep(i,a,b) for (int i = a;i <= b;i ++)
#define pre(i,a,b) for (int i = a;i >= b;i --)
#define REP(i,a,b) for (int i = a;i < b;i ++)

#define read(a,s,n) rep(i,s,n) scanf("%d",a + i);
#define READ(a,s,n) REP(i,s,n) scanf("%d",a + i);

#define read_ll(a,s,n) rep(i,s,n) scanf("%lld",a + i);
#define READ_ll(a,s,n) REP(i,s,n) scanf("%lld",a + i);

#define _T_(T) int T;scanf("%d",&T);while (T --)
#define __T _T_(TTESTCASES)
#define _E_(T) while (~T)

#define Tprint(a,s,e) {int f=1;REP(i,s,e){if(f)f=0;else printf(" ");printf("%d",a[i]);}}


#define endl '\n'

#define itn int
#define iny int
#define nit int
#define inr int
#define mian main
#define iman main
#define mina main
#define mian main
#define ednl endl
#define fro for
#define fir for
#define reutrn return
#define retunr return
#define reutnr return


/* header_useful_h */


int main(){
    
    ll a;
    scanf("%lld",&a);
    if (a >= 30) puts("Yes");
    else puts("No");
    
    return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;

struct Edge {
  int to;
};

using Graph = vector<vector<Edge>>;

vector<bool> seen;

void dfs(const Graph &G, int v) {
  seen[v] = true;
  for (auto e : G[v]) {
    if (!seen[e.to]) {
      dfs(G, e.to);
    }
  }
}

void solve() {
  int n, m;
  cin >> n >> m;

  Graph G(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back({b});
    G[b].push_back({a});
  }
  seen.assign(n, false);
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (!seen[i]) {
      dfs(G, i);
      cnt++;
    }
  }
  cout << cnt - 1 << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


Measured memory_bytes: 9536