akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int N,M,A[3000][3000];

int tmp;
int dp2[3000][2][2];
int solve2(int now, int old1, int old2){
	int x = now+tmp-N+1;
	int y = N-1-now;
	if(tmp < N-1){
		y -= N-tmp-1;
		x += N-tmp-1;
	}
	if(x == M || y == -1) return 0;
	if(dp2[now][old1][old2] != -1) return dp2[now][old1][old2];
	if(A[y][x] != 0) return solve2(now+1,0,old1);
	int re = solve2(now+1,0,old1);
	if(y+2<N && A[y+1][x]==1 && A[y+2][x]==2 && old1==0 && old2==0){
		re = max(re, solve2(now+1,0,old1)+1);
	}
	if(x+2<M && A[y][x+1]==1 && A[y][x+2]==2){
		re = max(re, solve2(now+1,1,old1)+1);
	}
	//cout << re << endl;
	return dp2[now][old1][old2] = re;
}

int dp1[6000];
int solve1(int now){
	if(now == N+M-3) return 0;
	if(dp1[now] != -1) return dp1[now];
	tmp = now;
	for(int i=0; i<min(N,M); i++){
		dp2[i][0][0] = -1;
		dp2[i][0][1] = -1;
		dp2[i][1][0] = -1;
		dp2[i][1][1] = -1;
	}
	dp1[now] = solve2(0,0,0);
	dp1[now] += solve1(now+1);
	//cout << dp1[now] << endl;
	return dp1[now];
}



int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);

	

	cin >> N >> M;
	/*for(int i=0; i<6; i++){
		for(int j=0; j<3; j++){
			int x =j+i-N+1;
			int y = N-1-j;
			if(i < N-1){
				y -= N-i-1;
				x += N-i-1;
			}
			cout << x << " " << y << endl;
		}
	}*/
	for(int i=0; i<N; i++){
		string S;
		cin >> S;
		for(int j=0; j<M; j++){
			if(S[j] == 'R') A[i][j] = 0;
			if(S[j] == 'G') A[i][j] = 1;
			if(S[j] == 'W') A[i][j] = 2;
		}
	}
	for(int i=0; i<N+M-3; i++) dp1[i] = -1;
	cout << solve1(0) << endl;

	return 0;
}


Measured memory_bytes: 38828
#include <stdio.h>

int main(void)
{
	int N,tmp;
	
	scanf("%d",&N);
	
	int a[N];
	for(int i=0;i<N;i++){
		if(i==N-1)
		{
			scanf("%d",&a[i]);
			
		}
		else {scanf("%d ",&a[i]);}
	}
	
	int count=0;
	
	for(int i=0;i<N-1;i++)
	{
		for(int j=0;j<N-i-1;j++)
		{
			if(a[j+1]<a[j])
			{
				tmp = a[j];
				a[j] = a[j+1];
				a[j+1] = tmp;
				count++;
			}
		}
		
	}
	for(int i = 0; i<N;i++)
	{
		if(i==N-1)
		{
			printf("%d\n",a[i]);
		}
		else {printf("%d",a[i]);}
		
		if(i<N-1)
		{
			printf(" ");
		}
		
	}
	
	printf("%d\n",count);
	
	return 0;
}



Measured memory_bytes: 2092
#include<bits/stdc++.h>
const int MN=200000+5,P=20101009;
using namespace std;
typedef long long ll;
template<typename T>inline T&IN(T&in){
	in=0;char c=getchar();int f=1;
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c))in=in*10+c-'0',c=getchar();
	return in*=f;
}
int n,m,ans;
int fa[MN],dep[MN],f[MN],ls[MN];
int nxt[MN],to[MN],h[MN],cnt;
void add(int u,int v){to[cnt]=v,nxt[cnt]=h[u],h[u]=cnt++;}
void cir(int u,int v){while(u!=v)ls[++ls[0]]=u,u=fa[u];}
void dfs(int u,int pa){
	fa[u]=pa;dep[u]=dep[pa]+1;f[u]=dep[u]%2?1:-1;
	for(int e=h[u],v=to[e];~e;e=nxt[e],v=to[e])if(v^pa&&dep[v]<dep[u]){
		if(dep[v]){cir(u,v);continue;}
		dfs(v,u),f[u]+=f[v];
	}
}
void work1(){
	if(f[1])return puts("-1"),void();
	for(int i=1;i<=n;++i)ans+=abs(f[i]);
	printf("%d\n",ans);
}
void work2(){
	if(f[1]%2)return puts("-1"),void();
	int del=-f[1]/2;ans+=abs(del);
	for(int u=ls[1];u;u=fa[u])f[u]+=del;
	for(int u=fa[ls[ls[0]]];u;u=fa[u])f[u]+=del;
	for(int i=1;i<=n;++i)ans+=abs(f[i]);
	printf("%d\n",ans);
}
void work3(){
	if(f[1])return puts("-1"),void();
	for(int i=1;i<=ls[0];++i)dep[ls[i]]=0,ls[i]=f[ls[i]];
	sort(ls+1,ls+ls[0]+1);int del=ls[ls[0]+1>>1];ans=abs(del);
	for(int i=1;i<=n;++i)if(dep[i])ans+=abs(f[i]);
	for(int i=1;i<=ls[0];++i)ans+=abs(ls[i]-del);
	printf("%d\n",ans);
}
void input(){
	IN(n),IN(m);memset(h,-1,sizeof h);
	for(int i=1,u,v;i<=m;++i)IN(u),IN(v),add(u,v),add(v,u);
	dfs(1,0);
	if(m==n-1)work1();
	else if(ls[0]%2)work3();
	else work2();
}
int main(){
	input();
	return 0;
}

Measured memory_bytes: 9600
#include<stdio.h>

int main(){
    int a, b, k, i;
    scanf("%d", &k);
    scanf("%d %d", &a, &b);
    for(i=a; i<=b; i++){
        if(i%k==0){
            printf("OK\n");
            return 0;
        }
    }
    printf("NG\n");
    return 0;
}


Measured memory_bytes: 1664
use std::io;
fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).ok();
    let strs: Vec<&str> = s.split_whitespace().collect();
    let d: f32 = strs[0].parse().unwrap();
    let t: f32 = strs[1].parse().unwrap();
    let s: f32 = strs[2].parse().unwrap();
    if d / s <= t {
        println!("Yes");
    } else {
        println!("No");
    }
}

Measured memory_bytes: 2192
a,b,c = gets.split.map(&:to_f)
puts 1.0/2.0 * a *b*Math::sin(c/180 *Math::PI)
puts a + b + Math::sqrt(a**2+b**2 - 2.0*a*b*Math::cos(c/180*Math::PI))
puts b * Math::sin(c/180*Math::PI)

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

#define rep(i,n) for(long long i = 0;i < n; i++)

using namespace std;

int main() {
    int n[3];
    rep(i,3){
        cin >> n[i];
    }
    vector<int> m(3);
    m[0] = n[0] + n[1];
    m[1] = n[1] + n[2];
    m[2] = n[0] + n[2];
    sort(m.begin(), m.end());
    cout << m[0] << endl;
}


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

int main(){
	string N ;
    cin >> N;
    
    if (N == "SUN"){
    	cout << 7 << endl;
    }
    else if( N == "MON") {
		cout << 6 << endl;
    }
    else if (N == "TUE"){
    	cout << 5 << endl;
    }
    else if (N == "WED") {
    	cout << 4 << endl;
	}
    else if (N == "THU") {
    cout << 3 << endl;
    }
    else if (N == "FRI") {
    cout << 2  << endl;
    }
    else if (N == "SAT" ){
    cout << 1 << endl;

	}
}

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)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef struct UnionFindTree{
    vector<int> par;
    
    UnionFindTree(int n){
        par.resize(n, -1);
    }
    
    int find(int x){
        if(par[x] < 0) return x;
        return par[x] = find(par[x]);
    }
    
    int size(int x){
        return -par[find(x)];
    }
    
    bool unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return false;
        if(size(x) < size(y)) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    bool same(int x, int y){
        return find(x) == find(y);
    }
}UF;

int main(){
    int n, q;
    scanf("%d%d", &n, &q);
    UF uf(n);
    rep(i, q){
        int c, x, y;
        scanf("%d%d%d", &c, &x, &y);
        if(c) printf("%d\n", uf.same(x, y));
        else uf.unite(x, y);
    }
}


Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int a, b; cin >> a >> b;
    int tmp = a-2*b;
    if (tmp < 0) tmp = 0;
    cout << tmp << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repR(i, n) for(int i = n; i >= 0; ++i)
#define FDS(i, n) for(ll i = 0; i < n; ++i)
#define FDSR(i, n) for(int i = n; i >= 0; ++i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define FORR(i, m, n) for(int i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define itn int
#define ednl endl
using namespace std;
typedef long long ll;
int main(){
	string S;
	ll K;
	cin>>S>>K;
	FDS(i,K){
		if(S[i]!='1'){
			cout<<S[i]<<endl;
			break;
		}
		else if(i==(K-1)){
			cout<<1<<endl;
		}
	}
}

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

using namespace std;

int main() {
  int64_t n;
  std::cin >> n;
  std::vector<int64_t> as(n);
  for (int64_t i = 0; i < n; ++i) {
    std::cin >> as[i];
    as[i] -= i + 1;
  }
  if (n == 1) {
    std::cout << 0 << std::endl;
    return 0;
  }
  std::sort(as.begin(), as.end());
  int64_t const b_min = as.front();
  int64_t const b_max = as.back();
  int64_t const b_mid = as[n / 2];
  int64_t sad_mid = 0;
  for (int64_t i = 0; i < n; ++i) {
    sad_mid += std::abs(as[i] - b_mid);
  }
  if (sad_mid == 0) {
    std::cout << 0 << std::endl;
    return 0;
  }
  int64_t ret = sad_mid;
  auto const over_b_mid_itr = std::upper_bound(as.begin(), as.end(), b_mid);
  auto over_b_itr = over_b_mid_itr;
  int64_t over_b_idx = over_b_itr - as.begin();
  int64_t b = b_mid + 1;
  for (; b <= b_max; ++b) {
    int64_t const sad = ret + over_b_idx - (n - over_b_idx);
    if (sad == 0) {
      std::cout << 0 << std::endl;
      return 0;
    }
    if (sad > ret) {
      break;
    }
    ret = sad;
    over_b_itr = std::upper_bound(as.begin(), as.end(), b);
    over_b_idx = over_b_itr - as.begin();
  }
  if (ret == sad_mid) {
    auto ge_b_itr = std::lower_bound(as.begin(), as.end(), b_mid);
    int64_t ge_b_idx = ge_b_itr - as.begin();
    b = b_mid - 1;
    for (; b >= b_min; --b) {
      int64_t const sad = ret + (n - ge_b_idx) - ge_b_idx;
      if (sad == 0) {
        std::cout << 0 << std::endl;
        return 0;
      }
      if (sad > ret) {
        break;
      }
      ret = sad;
      ge_b_itr = std::lower_bound(as.begin(), as.end(), b);
      ge_b_idx = ge_b_itr - as.begin();
    }
  }
  std::cout << ret << std::endl;
  return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>

int a[10001000],g[10000];
int top = 1, cnt = 0, n;

void add(){
  while(g[top] * 3 + 1 < n)
    {  
      top++;
      g[top] = g[top - 1] * 3 + 1;
    }
}
void sort(int a[], int id){
  int v, i, j;
  for(i = id + 1 ; i <= n ; i++)
    {
      v = a[i];
      j = i-id;
      while(j >= 1 && a[j] > v)
	{
	  a[j+id]=a[j];
	  j-=id;
	  cnt++;
        }
      a[j+id]=v;
    }
}
int main(){
  int i;
    
  scanf("%d",&n);
  g[1]=1;
  for(i = 1 ; i <= n ; i++)
    {
      scanf("%d",&a[i]);
    }
    
  add();
  for(i = top ; i >= 1 ; i--)
    {
      sort(a,g[i]);
    }
    
  printf("%d\n",top);
  for(i = top ; i >= 1 ; i--)
    {
      printf("%d ",g[i]);
    }
  printf("\n%d\n",cnt);
  for(i=1;i<=n;i++)
    {
      printf("%d\n",a[i]);
    }
  
  return 0;
}



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

using namespace std;


int main() 
{
    long long int x,k,ans,mi;
    cin>>x>>k;
    long long int h[100009],dp[100009];
    long long int i,j;
    for(i=1;i<=x;i++)
    {
        cin>>h[i];
        dp[i]=0;
    }
    dp[1]=0;
    dp[2]=abs(h[2]-h[1]);
    for(i=3;i<=x;i++)
    {
        mi=(abs(h[i]-h[i-1])+dp[i-1]);
        for(j=2;j<=k && i-j>=1;j++)
        {
            mi=min(mi,(abs(h[i]-h[i-j])+dp[i-j]));
        }
        dp[i]=mi;
    }
    ans=dp[x];
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 1792
s = input()
ans = 'Yes'
for i in range(len(s)//2):
    if s[i] != s[-i-1]:
        ans = 'No'
        break
        
s_s = s[:(len(s)-1)//2]
for i in range(len(s_s)//2):
    if s_s[i] != s_s[-i-1]:
        ans = 'No'
        break
        
s_e = s[(len(s)+3)//2 - 1:]
for i in range(len(s_e)//2):
    if s_e[i] != s_e[-i-1]:
        ans = 'No'
        break
        
print(ans)

Measured memory_bytes: 9056
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [tuple(map(int, l.split())) for l in sys.stdin]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

def main():
    n,k = LI()
    s = [int(c) for c in S()]
    a = []
    if s[0] == 0:
        a.append(0)
    t = s[0]
    c = 1
    for b in s[1:]:
        if t == b:
            c += 1
        else:
            a.append(c)
            c = 1
            t = b
    a.append(c)
    l = len(a)
    if l // 2 <= k:
        return sum(a)

    r = t = sum(a[:k*2+1])
    if l % 2 == 0:
        a.append(0)
        l += 1
    g = k * 2 + 1
    for i in range(k*2+1,l-1,2):
        t -= a[i-g] + a[i-g+1]
        t += a[i] + a[i+1]
        if r < t:
            r = t

    return r


print(main())



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

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








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

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    list<int> lis;
    int x;
    cin >> x;
    
    for(int i=0;i<x;++i)
    {
        int in;
        cin >> in;
        if(i % 2 == 0)
        {
            lis.push_back(in);
        }
        else
        {
            lis.push_front(in);
        }
    }
    if( x %2 == 0 )
    {
    for(const auto& a : lis)
    {
        cout << a << " ";
    }
    }
    else
    {
        for(auto it = lis.rbegin() ; it != lis.rend();++it)
        {
            cout << *it << " ";
        }
        
    }
    cout << "\n";
}


Measured memory_bytes: 8448
N, M = map(int, input().split())
dp = [0] * N
for _ in range(M):
    a = int(input())
    dp[a-1] = -1

k = 1000000007


for i in range(N):
    if dp[i] == -1:
        dp[i] = 0
        continue
    if i == 0:
        dp[i] = 1
        continue
    if i == 1:
        dp[i] = dp[i-1] + 1
        continue

    dp[i] = dp[i-1] + dp[i-2]
    dp[i] %= k



print(dp[-1])


Measured memory_bytes: 6900
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define pb push_back
#define vl vector
#define ff first
#define ss second
using namespace std;

bool cmp(pair<pair<string,ll>,ll> a,pair<pair<string,ll>,ll> b)
{
    if(a.ff.ff<b.ff.ff) return true;
    else if(a.ff.ff==b.ff.ff)
    {
        if(a.ff.ss>b.ff.ss) return true;
        else return false;
    }
    return false;
}

int main()
{
    ll a,b,i,j,n,t;
    cin>>n;
    vl<pair<pair<string,ll>,ll>> p;
    for(i=0;i<n;i++)
    {
        string s;
        cin>>s>>a;
        p.pb({{s,a},i+1});
    }
    sort(p.begin(),p.end(),cmp);
    for(i=0;i<n;i++) cout<<p[i].ss<<endl;
}

Measured memory_bytes: 3584
'''
研究室PCでの解答
'''
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 998244353
dir = [(-1,0),(1,0),(0,-1),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"


def main(a,b,c,d):
    dp = [[0]*(d+1) for i in range(c+1)]
    dp[a][b] = 1

    for i in range(a-1,c):
        for j in range(b-1,d):
            if i == a-1 and j == b-1:
                continue
            dpi = dp[i+1][j]*(i+1)+dp[i][j+1]*(j+1)-dp[i][j]*(i*j)
            dp[i+1][j+1] = dpi%mod

    return(dp[c][d])


    return None

if __name__ == '__main__':
    a,b,c,d = map(int,ipt().split())
    print(main(a,b,c,d))


Measured memory_bytes: 146264
// ~/BAU/ACM-ICPC/Teams/Rampage/Abukhadijah
// ~/Remember,remember the 6th of March.
#include <functional>
#include <iomanip>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include<complex>
#include <unordered_map>
#include<unordered_set>
#include <numeric>
#include <string>
#include<iostream>
#include <fstream>
#include <assert.h>
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include<cmath>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double  EPS = 1e-11;
const ll MOD = 1000000007;
const int N = 10000007;
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
void fast()
{
	std::ios_base::sync_with_stdio(0);
}

int main()
{
	string s;
	cin >> s;
	for (int i = 0; i < s.length(); i++)
		if (s[i] == '1')
			cout << 9;
		else
			cout << 1;
	cout << endl;

	return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    double n, d;
    double ans;
    cin >> n >> d;
    d *= 2.0;
    d++;
    ans = n / d;
    cout << ceil(ans) << "\n";
    return 0;
}

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

int main() {
	int n,m; cin>>n>>m;
	int arr[n];
	for(int i =0; i<n; i++)
		cin>>arr[i];
		
	vector<int> g[n+1];
	
	for(int i=0; i<m; i++){
		int u,v; cin>>u>>v;
		u--; v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	
	int rta = 0;
	
	for(int i=0; i<n; i++){
		bool flag  = true;
		for(auto&x : g[i]){
			if(g[i].size() == 0){
				break;
			}
			else if(arr[i]<=arr[x]){
				flag = false;
				break;
			}
		}
		if(flag)rta++;
	}
	cout<<rta<<endl;
}

Measured memory_bytes: 9144
#include<iostream>
#include<cstring>
#include<algorithm>

using namespace std;
const int N = 1e3 + 10;
char S[N],T[N];

int main(void)
{
	cin >> S >> T;
	
	int Max = 0;
	
	for(int r = strlen(T) - 1,l = 0; r < strlen(S); l ++ , r ++ )
	{
		int sum = 0;
		
		for(int j = 0 ; j < strlen(T) ; j ++)
		{
			if(S[l + j] == T[j]) sum ++ ;
		}
		
		Max = max(Max,sum);
	}
	
	//cout << Max << endl;
	
	cout << strlen(T) - Max;
	return 0;
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define Maxn 50007
#define Maxm 100007
using namespace std;
int n,m,T;
int x[Maxm],y[Maxm];
bitset<Maxn> f[Maxn];
vector<int> q[Maxn];
int id[Maxn];
bool vis[Maxn],ans[Maxm];
void solve1()
{
    for (int i=1;i<=n;i++)
    {
        f[i]=0;
        f[i][i]=1;
    }
    for (int i=1;i<=m;i++)
    {
        f[x[i]]=f[x[i]]|f[y[i]];
        f[y[i]]=f[x[i]];
    }
    int pos=-1;
    for (int i=1;i<=n;i++)
        if (f[i].count()==n)
        {
            pos=i;
            break;
        }
    if (pos==-1)
    {
        printf("%d\n",-1);
        return;
    }
    memset(vis,false,sizeof(vis));
    memset(ans,false,sizeof(ans));
    vis[pos]=true;
    for (int i=m;i;i--)
    {
        if (vis[x[i]]&&(!vis[y[i]])) ans[i]=true;
        if (vis[x[i]]||vis[y[i]])
        {
            vis[x[i]]=true;
            vis[y[i]]=true;
        }
    }
    for (int i=1;i<=m;i++)
        if (ans[i]) printf("^"); else printf("v");
    printf("\n");
}
void solve2()
{
    if (n==2)
    {
        printf("%d\n",-1);
        return;
    }
    memset(q,0,sizeof(q));
    for (int i=1;i<=m;i++)
    {
        q[x[i]].push_back(y[i]);
        q[y[i]].push_back(x[i]);
    }
    memset(id,0,sizeof(id));
    int a=x[1],b=y[1];
    b=b%n+1;
    if (a==b) b=b%n+1;
    for (int i=1;i<=m;i++)
    {
        ++id[x[i]];
        ++id[y[i]];
        if (x[i]!=a&&x[i]!=b&&y[i]!=a&&y[i]!=b) printf("^");
        else 
        {
            if (x[i]==b||y[i]==b) swap(a,b);
            if (id[b]==(int)q[b].size()||q[b][id[b]]!=x[i]+y[i]-a)
            {
                if (x[i]==a) printf("v"); else printf("^");
                a=x[i]+y[i]-a;
            } else
            {
                if (x[i]==a) printf("^"); else printf("v");
            }
        }
    }
    printf("\n");
}
int main()
{
    scanf("%d%d%d",&n,&m,&T);
    for (int i=1;i<=m;i++)
        scanf("%d%d",&x[i],&y[i]);
    if (T==1) solve1(); else solve2();
    return 0;
}

Measured memory_bytes: 307968
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner( System.in );
		
		// 入力
		int r = sc.nextInt();
		int c = sc.nextInt();
		
		int[][] vector = new int[r + 1][c + 1];
		
		for ( int iR = 0; iR < r; iR++ ) {
			for ( int iC = 0; iC < c; iC++ ) {
				vector[iR][iC] = sc.nextInt();
				
			}
		}
		
		// 計算
		for ( int iR = 0; iR < r; iR++ ) {
			for ( int iC = 0; iC < c; iC++ ) {
				vector[iR][c] += vector[iR][iC];
				
			}
		}
		
		for ( int iC = 0; iC < c; iC++ ) {
			for ( int iR = 0; iR < r; iR++ ) {
				vector[r][iC] += vector[iR][iC];
				vector[r][c] += vector[iR][iC];
			}
		}
				
		// 出力
		for ( int iR = 0; iR < r+1; iR++ ) {
			for ( int iC = 0; iC < c+1; iC++ ) {
				System.out.print(vector[iR][iC]);
				if( iC != c ) {
					System.out.print(" ");
					
				} else {
					System.out.println();
					
				}
			}
		}
		
		sc.close();
	}

}

Measured memory_bytes: 39044
n = int(input())
a = list(map(int,input().split()))
ans = 1
cnt_0 = a.count(0)
if cnt_0 >= 1:
    ans = 0
else:
    for i in range(n):
        ans *= a[i]
        if ans > 10 ** 18:
            ans = -1
            break
print(ans)

Measured memory_bytes: 21780
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    static int counter = 0;

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

        int[] list = new int[total];

        for (int k = 0; k < total; k++) {
            list[k] = inp.nextInt();
        }

        merge_sort(list, 0, total);

        StringBuilder pInt = new StringBuilder();
        
        int place = 0;
        for(int n : list) {
            if (place != 0) {
                pInt.append(" ").append(n);

            } else {
                pInt.append(n);
            }

            place++;
        }

        System.out.println(pInt);

        System.out.println(counter);
    }

    public static void merge(int[] a, int left, int mid, int right) {
        int n1 = mid - left;
        int n2 = right - mid;
        int[] l = new int[n1+1];
        int[] r = new int[n2+1];

        for (int i = 0; i < n1; i++) {
            l[i] = a[left + i];
        }

        for (int i = 0; i < n2; i++) {
            r[i] = a[mid + i];
        }

        l[n1] = Integer.MAX_VALUE;
        r[n2] = Integer.MAX_VALUE;

        int i = 0;
        int j = 0;

        for (int k = left; k < right; k++) {
            if (l[i] <= r[j]) {
                a[k] = l[i++];
            } else {
                a[k] = r[j++];
            }
            counter++;
        }
    }

    public static void merge_sort(int[] a, int left, int right) {
        if (left + 1 < right) {
            int mid = (left + right) / 2;
            merge_sort(a, left, mid);
            merge_sort(a, mid, right);
            merge(a, left, mid, right);
        }
    }
}


Measured memory_bytes: 179096
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    ll n, m;
    cin >> n >> m;
    if (!(n < m)) swap(n, m);

    if (n == 1 && m == 1) {
        cout << 1 << endl;
        ret();
    }

    if (n == 1) {
        cout << m - 2 << endl;
        ret();
    }

    cout << (n - 2) * (m - 2) << endl;

}


Measured memory_bytes: 3604
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>

struct asumikana {
	int A, B;
};

int nakagawasyouko(const void* x, const void* y) {
	int a = ((const struct asumikana*)x)->A, b = ((const struct asumikana*)y)->A;
	return a < b ? -1 : a > b;
}

int N, M;
struct asumikana kitaeri[114514];

int main(void) {
	int i;
	int64_t horiemituko = 0;
	int sinntaniryouko;
	if (scanf("%d%d", &N, &M) != 2) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d%d", &kitaeri[i].A, &kitaeri[i].B) != 2) return 1;
	}
	qsort(kitaeri, N, sizeof(*kitaeri), nakagawasyouko);
	sinntaniryouko = M;
	for (i = 0; i < N; i++) {
		if (sinntaniryouko <= kitaeri[i].B) {
			horiemituko += (int64_t)kitaeri[i].A * sinntaniryouko;
			break;
		} else {
			horiemituko += (int64_t)kitaeri[i].A * kitaeri[i].B;
			sinntaniryouko -= kitaeri[i].B;
		}
	}
	printf("%" PRId64 "\n", horiemituko);
	return 0;
}


Measured memory_bytes: 1788
#include<stdio.h>
int main()
{
	int j,m,n,p,q;
	int t[100000],x[100000],i[100000],sum[100000]={0},y[100000];
	scanf("%d",&n);
	for(j=1;j<=n;j++)
	{
		scanf("%d",&t[j]);
	}
	scanf("%d",&m);
	for(j=1;j<=m;j++)
	{
		scanf("%d %d",&i[j],&x[j]);
	}
	for(q=1;q<=n;q++)
	{
		y[q]=t[q];
	}
	for(j=1;j<=m;j++)
	{
		for(p=1;p<=n;p++)
		{
			t[i[j]]=x[j];
			sum[j]+=t[p];
		}
		for(q=1;q<=n;q++)
		{
			t[q]=y[q];
		}
	}
	for(j=1;j<=m;j++)
	{
		printf("%d\n",sum[j]);
	}
	return 0;
}

Measured memory_bytes: 512
if __name__ == '__main__':
    N = int(input())
    A, B = [list(map(int, input().split())) for l in range(2)]
    A_sum = sum(A)
    for i, brave in enumerate(B):
        A[i] -= brave
        if A[i] < 0:
            A[i+1] += A[i]
            if A[i+1] < 0:
                A[i+1] = 0
            A[i] = 0
            
    print(A_sum - sum(A))

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

int main()
{
    ios::sync_with_stdio(false);  cin.tie(0);
    int n ,k;
    long long res=0;
    cin >> n >>k;
    int arr[n];
    for (int i=0; i<n; i++)
        cin >> arr[i];

    sort (arr ,arr+n);
    for (int i=0; i<k; i++)
        res += arr[i];

    cout << res;
    return 0;
}

Measured memory_bytes: 3644
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

//組み合わせを線形で
//参考:https://drken1215.hatenablog.com/entry/2018/06/08/210000

const int MXN=1000001;//変更可
ll fac[MXN],inv[MXN],finv[MXN];

void COMinit(int M) {
    fac[0]=fac[1]=1;
    inv[1]=1;
    finv[0]=finv[1]=1;
    for(int i=2;i<MXN;i++){
        fac[i]=fac[i-1]*i%M;
        inv[i]=M-M/i*inv[M%i]%M;
        finv[i]=finv[i-1]*inv[i]%M;
    }
}

ll COMBI(int N,int K,int M){
    if(N<K){
        return 0;
    }
    if(N<0||K<0){
        return 0;
    }
    return fac[N]*finv[N-K]%M*finv[K]%M;
}

ll PERMU(int N,int K,int M){
    if(N<K){
        return 0;
    }
    if(N<0||K<0){
        return 0;
    }
    return fac[N]*finv[N-K]%M;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    COMinit(MOD);
    cout << fac[N] << endl;
}

Measured memory_bytes: 27088
<?php
fscanf(STDIN, "%d %d", $k,$x);

$result[] = $x;
for($i=1; $i<$k; $i++){
    $result[] = $x-$i;
    $result[] = $x+$i;
}

sort($result);
$ans = array_values($result);
for($s=0; $s<count($result); $s++){
    echo $ans[$s]." ";
}

?>  

Measured memory_bytes: 3828
from bisect import*
n,k,*a=map(int,open(0).read().split())
if 0 in a:
    k-=1
    a.remove(0)
#print(a)
ans=[]

x=bisect(a,0)
for i in range(-k,1):
    p=x+i
    q=x+i+k-1

    if 0<=p<n and 0<=q<n:
        #print(p,q)
        c=a[p]
        d=a[q]
        ans.append(abs(c)+abs(d-c))
        ans.append(abs(d)+abs(d-c))
#print(ans)
print(min(ans or [0]))

Measured memory_bytes: 14052
#include <stdio.h>

int main(void)
{
  int t[201];
  int taro[100]={0};
  int  hana[100]={0};
  int i, j, k, tmp, n ,now, tc, hc;
  tc = hc = 0;

  while(1){
    for(i = 0; i < 201; i++)
      t[i] = 0;
    scanf("%d", &n);
    if(n == 0) break;
    for(i = 0; i < n; i++){
      scanf("%d", &tmp);
      t[tmp] = 1;
    }

    j = k = 0;
    for(i = 1; i <= 2*n; i++){
      if(t[i] == 0)
	hana[j++] = i;
      else
	taro[k++] = i;
    }

    j = k = n;
    now = taro[0];
    taro[0] = 0;
    while(j != 0 && k-1 != 0){
      for(i = 0; i < n; i++){
	  if(now < hana[i]){
	  now = hana[i];
	  hana[i] = 0;
	  j--;
	  break;
	  }
	}
      if(i == n) now = 0;

	for(i = 1; i < n; i++){
	  if(now < taro[i]){
	    now = taro[i];
	    taro[i] = 0;
	    k--;
	    break;
	  }
	}
	if(i == n) now = 0;
      }
    for(i = 0; i < n; i++){
      if(taro[i] != 0) tc++;
      if(hana[i] != 0) hc++;
    }
      printf("%d\n%d\n", hc, tc);
      tc = hc = 0;
  }
  return 0;
}

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}

//char->int
int ctoi(char c){
    return c-'0';
}



int main(){
    ll n;
    cin >> n;
    vector<ll> a(3*n);
    rep(i,3*n) cin >> a[i];

    sort(a);
    

    ll ans = 0;


    for(int i=n;i<3*n;i+=2){
        ans+=a[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 2560
#include <stdio.h>
#include <string.h>

typedef struct {
	const char* name;
	int hosei;
} settouzi_t;

const settouzi_t settouzi_list[20]={
	{"yotta"	,	24	},
	{"zetta"	,	21	},
	{"exa"		,	18	},
	{"peta"		,	15	},
	{"tera"		,	12	},
	{"giga"		,	9	},
	{"mega"		,	6	},
	{"kilo"		,	3	},
	{"hecto"	,	2	},
	{"deca"		,	1	},
	{"deci"		,	-1	},
	{"centi"	,	-2	},
	{"milli"	,	-3	},
	{"micro"	,	-6	},
	{"nano"		,	-9	},
	{"pico"		,	-12	},
	{"femto"	,	-15	},
	{"ato"		,	-18	},
	{"zepto"	,	-21	},
	{"yocto"	,	-24	}
};

int main(void) {
	int data_num,cur_data;
	char num[1100];
	char settouzi[12];
	char tani[100];
	int hosei;
	int i;
	int dot_pos;
	int nonzero_pos;
	int num_length;
	scanf("%d",&data_num);
	for(cur_data=0;cur_data<data_num;cur_data++) {
		scanf("%s",num);
		scanf("%s",settouzi);
		hosei=0;
		for(i=0;i<20;i++) {
			if(strcmp(settouzi_list[i].name,settouzi)==0) {
				hosei=settouzi_list[i].hosei;
				break;
			}
		}
		if(hosei==0) {
			strcpy(tani,settouzi);
		} else {
			scanf("%s",tani);
		}
		num_length=strlen(num);
		dot_pos=num_length;
		nonzero_pos=-1;
		for(i=0;i<num_length;i++) {
			if(nonzero_pos<0 && num[i]!='.' && num[i]!='0')nonzero_pos=i;
			if(num[i]=='.')dot_pos=i;
		}
		hosei+=dot_pos-nonzero_pos;
		if(nonzero_pos<dot_pos)hosei--;
		putchar(num[nonzero_pos]);
		if(nonzero_pos<num_length-1)putchar('.');
		for(i=nonzero_pos+1;i<num_length;i++) {
			if(num[i]!='.')putchar(num[i]);
		}
		printf(" * 10^%d %s\n",hosei,tani);
	}
	return 0;
}

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


int main() {
  char x, y;
  cin >> x >> y;
  char ans = '=';
  if(x > y) ans = '>';
  else if( x < y) ans = '<';
  cout << ans << endl;
  return 0;
  
}

Measured memory_bytes: 256
import sys
import itertools
import numpy as np
from collections import Counter
import math

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, M = map(int, input().split(' '))
G = [[] for _ in range(N+1)]
ans = [0]*(N+1)
count = 0
for i in range(M):
    A, B = map(int, input().split(' '))
    G[A].append(B)
    G[B].append(A)

s = [1]
while count < N:
    ne = []
    for i in s:
        for j in G[i]:
            if ans[j] == 0:
                ans[j] = i
                count += 1
                ne.append(j)
    s = ne
print('Yes')
for i in ans[2:]:
    print(i)


Measured memory_bytes: 52492
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int ary[][] = new int[num][6];

		for(int i=0; i<num; i++){
			for(int j=0; j<6; j++){
				ary[i][j] = sc.nextInt();
			}
		}

		int ary2[] = new int[6];
		int ary3[] = new int[6];
		int co = 0;
		it: for(int i=0; i<num-1; i++){
			for(int j=i+1; j<num; j++){
				for(int k=0; k<6; k++){
					ary2[k]=ary[i][k];
					ary3[k]=ary[j][k];
				}
				co = plan(ary2,ary3);
				if(co==4)break it;
			}
		}

		if(co==4){
			System.out.println("No");
		}else{
			System.out.println("Yes");
		}}

	public static int plan(int[] d, int[] t){
		int sd1ary[] = {d[0], d[5], d[1], d[2], d[4], d[3]};
		int sd2ary[] = {t[0], t[1], t[2], t[3], t[4], t[5]};
		int sd3ary[][] =
			{{t[0], t[5], t[1], t[2], t[4], t[3]},
					{t[1], t[4], t[0], t[3], t[5], t[2]},
					{t[2], t[3], t[4], t[0], t[1], t[5]},
					{t[3], t[2], t[4], t[5], t[1], t[0]},
					{t[4], t[1], t[2], t[5], t[3], t[0]},
					{t[5], t[0], t[3], t[4], t[2], t[1]}};
		int count = 0;
		int add = 0;

		out : for(int k=0; k<6; k++){
			if(sd1ary[0] == sd2ary[k]){
				if(sd1ary[1]!=sd3ary[k][1])break;
				for(int j=2; j<6; j++){
					count=0;
					if(sd1ary[2]==sd3ary[k][j]){
						for(int n=0; n<4; n++){
							add = j+n;
							if(add>5) add=add-4;

							if(sd1ary[n+2]==sd3ary[k][add]){
								count++;
								if(count==4)break out;
							}
						}
					}
				}
			}
		}
		return count;
	}
}


Measured memory_bytes: 30676
A,B,M = [int(i) for i in input().split(' ')]
a = [int(i) for i in input().split(' ')]
b = [int(i) for i in input().split(' ')]

dis = [[int(i) for i in input().split(' ')] for j in range(M)]

ls = [min(a)+min(b)]

for d in dis:
  ans = a[d[0]-1] + b[d[1]-1] - d[2]
  ls.append(ans)
  
print(min(ls))

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  ll n;
  cin>>n;
  vector<ll> a(n);
  rep(i,n)
    cin>>a[i];
  double ans = 0;
  rep(i,n) {
    ans += 1.0/a[i];
  }
  ans = 1.0 / ans;
  printf("%.10f\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef vector<int> V;

int main() {
  string s, t = "CODEFESTIVAL2016";
  cin >> s;
  int cnt = 0;
  for (int i = 0; i < (int)s.size(); i++) if (s[i] != t[i]) cnt++;
  dump(cnt);
  return 0;
}


Measured memory_bytes: 256
import sys

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N = INT()
H = MAP()

max = 0
for h in H:
	if h >= max:
		max = h
		continue
	if h < max-1:
		#print(max, h)
		print('No')
		sys.exit()
print('Yes')

Measured memory_bytes: 14188
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
typedef long long ll;
const int MAX = 999999999;

int main(){
    string n;
    cin >> n;

    if(count(all(n), '9') > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long int ll;
const int N = 1000000;
const int mod = 1000000007;
const int INF = 1 << 30;
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define vin(v,n) rep(i,n)cin>>v[i];
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define sz size()
#define fi first
#define se second
#define pb push_back
#define prquete priority_queue<ll,vector<ll>,greater<ll>>
string YN(bool b) { return(b ? "YES" : "NO"); }
string yn(bool b) { return(b ? "Yes" : "No"); }
ll a, b, c, n, v[100010], ans = 0;
string s, ss, sss;
int main() {

	cin >> a>>b;

	cout<< (a<=b?a:a-1)<<endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
W = []
dic = dict()
yes = 1

for _ in range(N):
	char = str(input())
	W.append(char)
	if not char in dic:
		dic[char] = 1
	else:
		yes = 0

tale = W[0][0]
		
for i in range(N):
	if tale != W[i][0]:
		yes = 0
		break
	else:
		tale = W[i][-1]
		
if yes:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!$BDs=P;~$K%3%a%s%H%"%&%H(B!!
#ifdef DEBUG_
#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

    template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int mod = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);
const long double PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;
int dx[] = {0,0,-1,1};
int dy[] = {-1,1,0,0};

VVI g;
VI color;
bool ok = true;

void check(int v, int c){
    color[v] = c;
    for(int u : g[v]){
        if(color[u] == c){
            ok = false;
        }else if(color[u] == 0){
            check(u,c*-1);
        }
    }
}


signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    int N; cin >> N;
    g.resize(N);
    VS S(N);
    REP(i,N){
        cin >> S[i];
        REP(j,N){
            if(S[i][j] == '1'){
                g[i].eb(j);
            }
        }
    }
    color.resize(N);
    check(0,1);
    if(!ok){
        cout << -1 << endl;
        return 0;
    }
    int ans = 0;
    REP(i,N){
        VI num(N);
        queue<PII> q;
        q.push(PII(i,1));
        num[i] = 1;
        while(!q.empty()){
            int v,c;
            tie(v,c) = q.front();
            q.pop();
            for(int u : g[v]){
                if(num[u] != 0) continue;
                num[u] = c+1;
                q.push(PII(u,c+1));
            }
        }
        int MAX = 0;
        REP(i,N){
            chmax(MAX,num[i]);
        }
        chmax(ans,MAX);
    }
    cout << ans << endl;


}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0094
"""
import sys


def sm_to_tsubo(a, b):
    return (a * b / 3.305785)



def main(args):
    for line in sys.stdin:
        a, b, = [int(x) for x in line.strip().split(' ')]
        result = sm_to_tsubo(a, b)
        print('{:.6f}'.format(result))

if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 7712
#include <iostream>
#include <string>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
using namespace std;


int main(void) {
    string a;
    string b;
    cin >>a;
    cin >>b;
    int target;
    target = stoi(a + b);
    
    for (int i = 0; i < (target / 2); i++) {
        if (i * i == target) {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {

			int a = sc.nextInt();
			int b = sc.nextInt();
			
			int add = a + b;
			int diff = a - b;
			int mult = a * b;
			
			int max = add;
			
			if ( max < diff) {
				max = diff;
			}
			
			if ( max < mult ) {
				max = mult;
			}
			
			System.out.println(max);
			
		}
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <cmath>
#include <iomanip>
#include <utility>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#define ll long long
         
using namespace std;
     
long long gcd(int x, int y){
     if ( x == 0 ) return y;
     
     return gcd(y%x, x);
}
     
long long lcm(int x, int y){
     if ( y == 0 ){
          return x;
     }
     
     return x*y/gcd(x, y);
}
     
int min(int a, int b){
     return a > b ? b : a;
}
     
int max(int a, int b){
     return a > b ? a : b;
}

int main()
{
     cin.sync_with_stdio( false );

     int n;
     cin>>n;

     int k;
     cin>>k;

     map <int, int> m;
     for (int i=0;i<k;i++){
          int d;
          cin>>d;

          for (int j=0;j<d;j++){

               int a;
               cin>>a;

               m[a]++;
          }
     }

     int br = 0;
     for (int i=1;i<=n;i++){
          if ( m[i] == 0 ){
               br++;
          }

     }

     cout<<br<<endl;
}

Measured memory_bytes: 3636
n, m = [int(n) for n in input().split()]

p = []
for i in range(n):
    p.append([int(n) for n in input().split()])

check_point = []
for j in range(m):
    check_point.append([int(n) for n in input().split()])

for i in range(n):
    l = []
    for j in range(m):
        delta = abs(p[i][0] - check_point[j][0]) + abs(p[i][1] - check_point[j][1])
        l.append(delta)

    print(l.index(min(l))+1)

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include <sstream>
using namespace std;
int main(void){
    int n,i,ans,r_up;
    cin >> n;
    ans = 100000;
    for(i = 0; i < n; i++){
        ans += ans * 0.05;
        r_up = ans % 1000;
        if(r_up != 0){
            ans += (1000 - r_up);
        }
    }
    cout << ans << endl;
    return 0;
}

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

const int N = 200005;

int n;
string s[N];

struct Node {
  Node *child[26];
  int val[26];

  Node() {
    for (int i = 0; i < 26; ++i) {
      val[i] = 0;
      child[i] = 0;
    }
  }
};

Node *root;

void add(const string &s) {
  vector<Node*> path;
  path.push_back(root);
  for (int i = (int) s.size() - 1; i >= 0; --i) {
    if (!(path.back()->child[s[i] - 'a'])) {
      path.back()->child[s[i] - 'a'] = new Node();
    }
    path.push_back(path.back()->child[s[i] - 'a']);
  }

  int mask = 0;
  path.pop_back();
  for (int i = 0; i < s.size(); ++i) {
    mask |= (1 << (s[i] - 'a'));
    for (int j = 0; j < 26; ++j) {
      path.back()->val[j] += (mask >> j & 1);
    }
    path.pop_back();
  }
}

int query(const string &s) {
  Node *cur = root;
  for (int i = (int) s.size() - 1; i > 0; --i) {
    if (!(cur->child[s[i] - 'a'])) return 0;
    cur = cur->child[s[i] - 'a'];
  }

  return cur->val[s[0] - 'a'];
}

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

  root = new Node();

  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    ans += query(s[i]);
    // cerr << ans << endl;
    add(s[i]);
  }

  root = new Node();

  for (int i = n-1; i >= 0; --i) {
    ans += query(s[i]);
    // cerr << ans << endl;
    add(s[i]);
  }

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

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  // scanf("%d", &t);
  while (t--) solve();
  return 0;
}


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

int main(){
string s;
  cin >> s;
  int i,sum=0;
  for(i=0;i<s.size();i++){
    sum+=(s[i]-'0');
  }
  if(sum%9==0){
    cout << "Yes" <<endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3732