akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
typedef long long ll;

#define MAX(x, y)	(((x) > (y))? (x) : (y))
#define MIN(x, y)	(((x) < (y))? (x) : (y))
#define ABS(x)		(((x) < 0)? (-1*(x)) : (x))
#define REPI(x,y)	for (int i=(x);i<(y);i++)
#define REPJ(x,y)	for (int j=(x);j<(y);j++)
#define MEMCLR(X)	memset((X),0,sizeof((X)))

using namespace std;
typedef vector<vector<pair<int, int>>> GRA;

int i,j,N,K,ma,mi=1000000,mai,mii;

int main() {
	cin >> N;
	
	vector<int> A(N);

	REPI(0,N) {
		cin >> A[i];
		if (A[i]>ma) {
			ma = A[i];
			mai = i;
		} else if (A[i]<mi) {
			mi = A[i];
			mii = i;
		}
	}

	cout << (2*N-1) << endl;
	
	REPI(1,N+1) {
		if (ABS(ma)>=ABS(mi)) cout << (mai+1) << " " << i << endl;
		else cout << (mii+1) << " " << i << endl;
		
	}

	REPI(0,N-1) {
		if (ABS(ma)>=ABS(mi)) cout << (i+1) << " " << i+2 << endl;
		else cout << (N-i) << " " << (N-i-1) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - Ringo's Favorite Numbers
            var line = ReadLine();
            int d = line[0];
            int n = line[1];

            int baseNum = (int)Math.Pow(100, d);

            if (n == 100)
            {
                n++;
            }

            Console.WriteLine(baseNum * n);            
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 13268
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

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

    rep(i, s.size()){
        if(s[i]=='a')continue;
        ll a = 'z'-s[i]+1;
        if(a > k)continue;
        s[i] = 'a';
        k-=a;
    }
    k%=26;
    while(k!=0){
        if(s.back()=='z')s.back()='a';
        else s.back()+=1;
        k--;
    }
    cout << s << endl;
}

Measured memory_bytes: 512
n = int(input())
a = list(map(int, input().split()))

pos = []
neg = []
zero = []
for i in range(n):
    if a[i] < 0:
        neg += [i]
    elif a[i] == 0:
        zero += [i]
    else:
        pos += [i]

if zero != [] or (pos != [] and neg != []):
    best = 0
    for i in range(n):
        best += abs(a[i])
    print(best)
else:
    best = 0
    for i in range(n):
        best += abs(a[i])
    if pos == []:
        best -= abs(max(a)) * 2
    else:
        best -= abs(min(a)) * 2
    print(best)

if len(pos) < len(neg):
    pos += zero
    pos.sort()
else:
    neg += zero
    neg.sort()

np = len(pos)
nn = len(neg)
if np == 0 or nn == 0:
    if np == 0: #negative
        index = a.index(max(a))
        x = a[index]
        for i in range(n):
            if i == index:
                continue
            y = a[i]
            print(x, y)
            x -= y
    else: #positive
        index = a.index(min(a))
        x = a[index]
        flag = 0
        if index == 0:
            flag = 1
            
        for i in range(n):
            if i == index or i == flag:
                continue
            y = a[i]
            print(x, y)
            x -= y
        x, y = a[flag], x
        print(x, y)
else:
    x = a[neg[0]]
    for k in range(np-1):
        y = a[pos[k]]
        print(x, y)
        x -= y
        
    y = x
    x = a[pos[np-1]]
    print(x, y)
    x -= y
    for k in range(1, nn):
        y = a[neg[k]]
        print(x, y)
        x -= y

Measured memory_bytes: 61076
#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long

int main()
{
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    string s;
    cin>>s;
    
    if(s[0]==s[1] || s[1]==s[2] || s[2]==s[3])
    {
        cout<<"Bad"<<endl;
    }
    else
    {
        cout<<"Good"<<endl;
    }
}

Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int n;
    cin >> n;

    cout << n * n * n << "\n";
    return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define intt long long int
#define intu unsigned long long int
#define vi vector<int>
#define ii pair<int,int>
#define pb push_back
//#define mp make_pair
#define ff first
#define ss second
#define fast_io ios::sync_with_stdio(0);cin.tie(NULL);std::cout.tie(NULL);
# define PI           3.14159265358979323846 
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
int mod = 1000000007;
int gcd(int a, int b) {return b ? gcd(b, a % b) : a;}
int lcm(int a, int b) {return a * b / gcd(a, b); }
intt bpow(intt a,intt b) 
{
  intt res = 1;
  while (b > 0) {
    if (b & 1)res = res * a;
      a = a * a;
      b >>= 1;
  }
  return res;
}
intt fact(intt n) { 
   if ((n==0)||(n==1))
      return 1; 
   else
      return n*fact(n-1);
}
void go()
{
#ifndef ONLINE_JUDGE
  freopen("in.txt","r",stdin);
  freopen("out.txt","w",stdout);
  #endif
}

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

int tm,am;

vector<int> adj[200005];
int vis[200005];
int arr[200005];
int in[200005];
int out[200005];


int main() 
{ 
    fast_io
    go();
    intt n;cin>>n;
    string s="";
    while(n>0)
    {
      intt rem=n%26;
      if(rem==0)
      {
        s+='z';
        n=n/26-1;
      }
      else
      {
        s+=(char)('a'+ rem-1);
        n/=26;
      }
    }
    reverse(s.begin(),s.end());
    cout << s <<endl;
    

} 

/*!
    You are under no obligation to be the same person you were a minute ago,
    You have the right to grow !
*/




















Measured memory_bytes: 8368
#include <stdio.h>

int main(){
  int i, j, s, t, N, A[1000];
  
  scanf("%d", &N );
  
  for(i=0; N>i; i++){
    scanf("%d", &A[i]);
  }

  for(i=1; N>i; i++){
    for(j=0; j<N-1; j++){
      printf("%d ", A[j]);
    }
    printf("%d\n", A[N-1] );
    s = A[i];
    t = i-1;
    while (t >=0 && s < A[t]) {
      A[t+1] = A[t];
      t--;
    }
    A[t+1] = s;
  }
  for(j=0; j<N-1; j++){
    printf("%d ", A[j]);
  }
  printf("%d\n", A[N-1]);
  return 0;
}



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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 200007 , __ = _<<1 , lglg = 17 , inf = 0x3f3f3f3f;

int n;

struct trees
{
	int to[__],ne[__],he[_],ecnt;
	inline void adde(int a,int b){to[++ecnt]=b,ne[ecnt]=he[a],he[a]=ecnt;}
	inline void addde(int a,int b){adde(a,b),adde(b,a);}

	int fa[_],dep[_],sz[_],mxch[_];

	void dfs(int x,int ff)
	{
		fa[x]=ff,dep[x]=dep[ff]+1,sz[x]=1;
		for(int i=he[x];i;i=ne[i])
		{
			int b=to[i];
			if(b==ff)continue;
			dfs(b,x),sz[x]+=sz[b];
			if(sz[mxch[x]]<sz[b])mxch[x]=b;
		}
	}

	int top[_];
	
	void dfs2(int x,int tp)
	{
		top[x]=tp;
		if(mxch[x])dfs2(mxch[x],tp);
		for(int i=he[x];i;i=ne[i])
		{
			int b=to[i];
			if(b==fa[x] || b==mxch[x])continue;
			dfs2(b,b);
		}
	}

	inline int lca(int a,int b)
	{
		while(top[a]!=top[b])
		{
			if(dep[top[a]]<dep[top[b]])swap(a,b);
			a=fa[top[a]];
		}
		if(dep[a]>dep[b])swap(a,b);
		return a;
	}

	inline int distan(int a,int b)
	{
		return dep[a]+dep[b]-2*dep[lca(a,b)];
	}

	int rt;
	
	inline void make(int rt_)
	{
		rt=rt_,dfs(rt,0),dfs2(rt,rt);
	}

	trees()
	{
		memset(he,0,sizeof(he)),ecnt=1;
		memset(fa,0,sizeof(fa));
		memset(dep,0,sizeof(dep));
		memset(sz,0,sizeof(sz));
		memset(mxch,0,sizeof(mxch));
		memset(top,0,sizeof(top));
	}
}t1,t2;

int st1,st2,ans=0;

void dfs(int x)
{
	if(t1.dep[x]>=t2.dep[x])return;
	ans=max(ans,t2.dep[x]-1);
	for(int i=t1.he[x];i;i=t1.ne[i])
	{
		int b=t1.to[i];
		if(b==t1.fa[x])continue;
		if(t2.distan(x,b)>=3){ans=inf;return;}
		dfs(b);
	}
}
			

int main()
{
	n=ty(),st1=ty(),st2=ty();
	for(int i=1,a,b;i<n;i++)a=ty(),b=ty(),t1.addde(a,b);
	for(int i=1,a,b;i<n;i++)a=ty(),b=ty(),t2.addde(a,b);

	t1.make(st1),t2.make(st2);
	dfs(st1);
	if(ans>=inf)ans=-1;
	else ans<<=1;
	printf("%d\n",ans);

	return 0;
}


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

using namespace std;

typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli>> mat;
typedef vector<unordered_map<lli,lli>> graph;

const lli mod = 1000000007;

lli n;
vll a;

lli b;

lli factorial(lli n){
  static lli dp[100000];
  if(dp[n]) return dp[n];
  if(n == 0) return dp[n] = 1;
  return dp[n] = (n*factorial(n-1))%mod;
}

lli pow(lli x,lli r,lli mod = 1000000007){
  lli ret = 1;
  for(;r != 0;r >>= 1){
    if(r&1 != 0) ret *= x,ret %= mod;
    x *= x,x %= mod;
  }
  return ret;
}

lli inverse(lli x,lli mod = 1000000007){
  return pow(x,mod-2,mod);
}

lli combination(lli n,lli m,lli mod = 1000000007){
  if(n < m) return 0;
  return (((factorial(n)*inverse(factorial(m)))%mod)*inverse(factorial(n-m)))%mod;
}

int main(){
  cin >> n;
  a = vll(n+1);
  for(lli i = 1;i <= n+1;i++){
    lli x;
    cin >> x;
    if(a[x] != 0) b = i-a[x]-1;
    else a[x] = i;
  }
  cout << n << endl;
  n++;
  for(lli k = 2;k <= n;k++){
    cout << (combination(n-2,k)+2*combination(n-2,k-1)-combination(n-2-b,k-1)+combination(n-2,k-2)+mod)%mod << endl;
  }
  return 0;

}


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

int main() {
  int N;
  cin >> N;

  set<int> A;
  for (int i = 0; i < N; i++){
    int n;
    cin >> n;
    if (A.count(n)){
      cout << "NO" << endl;
      return 0;
    }
    A.insert(n);
  }
  cout << "YES" << endl;
}



Measured memory_bytes: 9600
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card {
  char suit;
  int value;
};

struct Card L[MAX/2+2], R[MAX/2+2];

void merge(struct Card A[], int n, int left, int mid, int right){
  int i,j;
  int k;
  int n1 = mid - left;
  int n2 = right - mid;

  for(i=0; i<n1; i++) L[i] = A[left + i];
  for(i=0; i<n2; i++) R[i] = A[mid + i];
  L[n1].value = R[n2].value = SENTINEL;

  i = 0;
  j = 0;

  for(k=left; k<right; k++){
    if(L[i].value <= R[j].value){
      A[k] = L[i++];
    }
    else{
      A[k] = R[j++];
    }
  }
}

void mergeSort(struct Card A[], int n, int left, int right){
  int mid;
  if(left+1 < right){
    mid = (left + right)/2;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }
}

int partition(struct Card A[], int n, int p, int r){
  int i,j;
  struct Card t;
  struct Card x;
  x = A[r];
  i = p-1;
  for(j=p; j<r; j++){
    if(A[j].value <= x.value){
      i++;
      t = A[i];
      A[i] = A[j];
      A[j] = t;
    }
  }
  t = A[i+1];
  A[i+1] = A[r];
  A[r] = t;
  return i+1;
}

void quickSort(struct Card A[], int n, int p, int r){
  int q;
  if(p<r){
    q = partition(A, n, p, r);
    quickSort(A, n, p, q-1);
    quickSort(A, n, q+1, r);
  }
}

int main(){
  int i;
  int n;
  int v;

  struct Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;

  scanf("%d", &n);

  for(i=0; i<n; i++){
    scanf("%s%d", S, &v);
    A[i].suit = B[i].suit = S[0];
    A[i].value = B[i].value = v;
  }

  mergeSort(A, n, 0, n);
  quickSort(B, n, 0, n-1);
  
  for(i=0; i<n; i++){
    if(A[i].suit != B[i].suit) stable = 0;
  }

  if(stable == 1) printf("Stable\n");
  else printf("Not stable\n");
  for(i=0; i<n; i++){
    printf("%c %d\n", B[i].suit, B[i].value);
  }
  return 0;
}



Measured memory_bytes: 4008
#include <iostream>
#include <algorithm>//cope
using namespace std;

int partition(int A[], int p, int r){

 int x=A[r];
 int i=p-1;
 for (int j=p;j<=r-1;j++){
	if (A[j]<=x){
		i=i+1;
		swap(A[i],A[j]);
	}
 }
 swap(A[i+1],A[r]);
 return i+1;
}


int main(){

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

 int q=partition(A,0,n-1);

 for (int i=0;i<n;i++){
	if(i==q){
		cout<<'['<<A[i]<<']';
	}
	else{
		cout<<A[i];
	}
	if(i<n-1){
		cout<<' ';
	}
	else{
		cout<<endl;
	}
 }

 return 0;
}

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

using namespace std;

void solve() {
    int a, b, c, d;
    cin >> a >> b>> c >> d;
    int left = min(a, c), right = max(b, d);
    int ans = 0;
    for (int i=left; i<=right; ++i) {
        if ((i >= a) && (i <= b) && (i>=c) && (i <=d))
            ans += 1;
    }
    cout << (ans >0 ? ans-1 : 0);
}

int main() {

	solve();
    return 0;
}


Measured memory_bytes: 3208
// 問題の URL を書いておく
// 

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <bitset>
#include <numeric>
using namespace std;

//#define ENABLE_PRINT

template<typename T>
T Input()
{
    T v;
    cin >> v;
    return v;
}

template<typename T>
vector<T> InputVector(int n)
{
    vector<T> v(n);
    for(int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
    return v;
}

template<typename T>
void InputArray(T* begin, int n)
{
    for(int i = 0; i < n; ++i)
    {
        cin >> begin[i];
    }
}

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

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

int main(int, const char**)
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while(true)
    {
        c -= b;
        if(c <= 0)
        {
            cout << "Yes" << endl;
            return 0;
        }

        a -= d;
        if(a <= 0)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3580
ball_name1,ball_name2 = input().split(" ")
ball1,ball2 = input().split(" ")
ball1 = int(ball1)
ball2 = int(ball2)
ball_chosen = input()


if (ball_chosen in ball_name1) :
    ball1-=1
    print(str(ball1)+" "+str(ball2))
else:
    ball2-=1
    print(str(ball1)+" "+str(ball2))

Measured memory_bytes: 3060
l=[100000 for i in range(100001)]
l[0]=0
dif=[1,6,9,36,81,216,729,1296,6561,7776,46656,59049]
for i in range(1,100001):
    for j in dif:
        if j>i: break
        l[i]=min(l[i],l[i-j]+1)
n=int(input())
print(l[n])

Measured memory_bytes: 3864
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication9
{
    class Program
    {
        static void Main(string[] args)
        {

            String[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            String op = str[1];
            int b = int.Parse(str[2]);
            int x=0;
            while (op != "?")
            {
                if (op == "+")
                {
                    x = a + b;
                }
                else if (op=="-")
                {
                    x = a - b;
                }
                else if (op=="*")
                {
                    x = a * b;
                }else if(op=="/")
                {
                    x = a / b;
                }
                Console.WriteLine(x);
                str = Console.ReadLine().Split(' ');
                a = int.Parse(str[0]);
                op = str[1];
                b = int.Parse(str[2]);
            }




        }
    }
}

Measured memory_bytes: 5612
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

#ifdef _DEBUG
#include "../../../library/library/debug_template.cpp"
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

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

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	vector<string> S(N);
	for (int i = 0; i < N; i++) cin >> S[i];

	vector<pair<int, int>> l, r;
	for (int i = 0; i < N; i++) {
		int sum = 0, m = 0;;
		for (const auto &c : S[i]) {
			sum += (c == '(') - (c == ')');
			chmin(m, sum);
		}
		if (sum > 0) l.emplace_back(m, sum);
		else r.emplace_back(m - sum, -sum);
	}

	sort(l.begin(), l.end(), greater<>());
	sort(r.begin(), r.end(), greater<>());
	DMP(l, r);

	auto check = [](auto &vec) {
		int sum = 0;
		for (int i = 0; i < vec.size(); i++) {
			if (sum + vec[i].first < 0) return -1;
			sum += vec[i].second;
		}
		return sum;
	};

	if (int res = check(l); res != -1 && res == check(r)) cout << "Yes" << "\n";
	else cout << "No" << "\n";

	return 0;
}

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

string s;
void solve(){
    cin >> s;
    int count = 0;
    for(int i=0; i<s.length()/2; i++){
        if(s[i] != s[s.length()-1-i]){
            count ++ ;
        }
    }
    cout << count << endl;
}
int main(){

    solve();
    
}

Measured memory_bytes: 256
////////////////////////////////////
////////////////////////////////////
////                            ////
////                            ////
////     Please give me AC!     ////
////     Please give me AC!     ////
////                            ////
////                            ////
////////////////////////////////////
////////////////////////////////////
#include <bits/stdc++.h>
using namespace std;
const int MOD=13;
int mod_pow(int x,int y){//x^yを返す//計算量は0(log(y))
  int t=x,r=1;
  while(y){
    if(y%2){r=r*t%MOD;}
    y>>=1;
    t=t*t%MOD;
  }
  return r;
}
int main(){
  string S;
  cin>>S;
  long long dp[100020][26];
  int dpcopy[13],mod=1e9+7;
  for(int i=1;i<=(int)S.size();i++){
    if(S.at(i-1)=='?'){
      for(int j=0;j<13;j++){
        if(i==1 && j<10){
          int w=(int)S.size()-1;
          int a=mod_pow(10,w)*j;
          a%=13;
          dp[1][a]=1;
        }
        else if(i>1){
          for(int k=0;k<13;k++){
            dpcopy[k]=dp[i-1][k];
          }
          for(int k=0;k<10;k++){
            int w=(int)S.size()-i;
            int a=mod_pow(10,w)*k;
            a%=13;
            dp[i][j]+=dpcopy[(j-a+13)%13];
            dp[i][j]%=mod;
          }
          for(int k=0;k<13;k++){
            dp[i-1][k]=dpcopy[k];
          }
        }
      }
    }
    else{
      if(i==1){
        int w=(int)S.size()-i;
        int a=mod_pow(10,w)*(S.at(i-1)-'0');
        a%=13;
        dp[1][a]=1;
      }
      else{
        for(int j=0;j<13;j++){
          dpcopy[j]=dp[i-1][j];
        }
        int w=(int)S.size()-i;
        int a=mod_pow(10,w)*(S.at(i-1)-'0');
        a%=13;
        for(int j=0;j<13;j++){
          dp[i][j]=dpcopy[(j-a+13)%13];
        }
        for(int j=0;j<13;j++){
          dp[i-1][j]=dpcopy[j];
        }
      }
    }
  }
  cout<<dp[(int)S.size()][5]<<endl;
}

Measured memory_bytes: 24032
X, Y = [int(_) for _ in input().split()]

ans = 0
V = [400000, 300000, 200000, 100000]
if X <= 3:
    ans += V[X]
if Y <= 3:
    ans += V[Y]
if X == Y == 1:
    ans += V[0]

print(ans)


Measured memory_bytes: 2940
import math
a, b, x = map(int, input().split())
if x >= a * a * b * 0.5:
	y = (2 * (a * a * b - x)) / (a ** 2)
	z = a
else:
	y = b
	z = (2 * x) / (a * b)
if y < z:
	print(math.degrees(math.atan(y / z)))
else:
	print(90 - math.degrees(math.atan(z / y)))

Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	k := r.nextInt()
	r.Scan(true)
	s := r.nextString()
	if len(s) > k {
		s = s[0:k] + "..."
	}

	fmt.Fprintln(stdout, s)
}


Measured memory_bytes: 1740
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner( System.in );
		
		while( true ) {
			int height	= sc.nextInt();
			int width	= sc.nextInt();
			
			if ( height	== 0 &&	width	== 0 ) break;
			
			for (int i = 0; i < height; i++ ) {
				if( ( i % 2 ) == 0 ) {
					even( width );
					
				} else {
					odd( width );
					
				}
				
			}
			
			System.out.print("\n");
			
		}
	}

	public static void even( int width ) {
		for (int i = 0; i < width; i++ ) {
			if( ( i % 2 ) == 0 ) {
				System.out.print("#");

			} else {
				System.out.print(".");
				
			}

		}
		
		System.out.print("\n");

	}
	
	public static void odd( int width ) {
		for (int i = 0; i < width; i++ ) {
			if( ( i % 2 ) == 0 ) {
				System.out.print(".");

			} else {
				System.out.print("#");
				
			}

		}
		
		System.out.print("\n");
	}
	
	
}

Measured memory_bytes: 31980
// AOJ 2000 "Misterious Gems" (ICPC模擬国内予選 2006 Problem A)
#include <iostream>
#include <cstring>

using namespace std;

int main() {
    while (true) {
        int field[21][21]; // フィールドの縦、横の座標
        int N; // 宝石の個数
        int M; // 命令の個数
        int positionX = 10; // ロボットの位置のx座標
        int positionY = 10; // ロボットの位置のy座標
        int dx[] = {0, 1, 0, -1};
        int dy[] = {1, 0, -1, 0};
        memset(field, 0, sizeof(field));
        
        cin >> N;
        if (N == 0) {
            break;
        }
        for (int i = 0; i < N; i++) {
            int x, y;
            cin >> x >> y;
            field[y][x] = 1;
        }
        
        cin >> M;
        for (int i = 0; i < M; i++) {
            char direction;
            int dir;
            int distance;
            cin >> direction >> distance;
            switch (direction) {
            case 'N':
                dir = 0;
                break;
            case 'E':
                dir = 1;
                break;
            case 'S':
                dir = 2;
                break;
            case 'W':
                dir = 3;
                break;
            }
            for (int j = 0; j < distance; j++) {
                positionX += dx[dir];
                positionY += dy[dir];
                field[positionY][positionX] = 0;
            }
        }
        
        bool ans = true;
        for (int i = 0; i < 21; i++) {
            for (int j = 0; j < 21; j++) {
                if (field[i][j] == 1) {
                    ans = false;
                }
            }
        }
        if (ans) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// __uint128_t
const ll MOD = 998244353;

ll f(ll X, ll M){
    return X%M;
}

int main(){
    ll N, X, M; cin >> N >> X >> M;
    ll SUM = X;
    vector<ll> A; A.push_back(X);
    vector<ll> ID(M+1, -1); ID[X] = 0;

    for(int cnt = 1; cnt < N; cnt++){
        X = f(X*X, M);
        A.push_back(X);
        //cout << X << " " << cnt << endl;
        if(ID[X] != -1){
            ll loop = 0; //ループでの総和
            ll n = cnt - ID[X]; //ループにかかる数
            ll n2 = max(ID[X], 0LL); // ループに入るまでの最初の数
            for(int i = ID[X]; i < cnt; i++) loop += A[i];
            ll n3 = (N - (n2))/n; //ループできる数
            SUM += (n3-1) * loop;
            ll n4 = N - n2 - n3*n; // 残り
            for(int i = 0; i < n4; i++) SUM += A[ID[X]+i];
            //cout << n2 << " " << n << " " << n3 << " " << n4 << endl;
            break;

        }
        SUM += X;
        ID[X] = cnt;
    }
    cout << SUM << endl;



}


Measured memory_bytes: 4660
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b;
  cin>>a>>b;
  int x=0,y=0;
  for(int i=0;i<a;i++)
  {
      x = x*10 + b;
  }
  for(int i=0;i<b;i++)
  {
      y = y*10 + a;
  }
  //cout<<x<<" "<<y<<endl;
  cout<<max(x,y);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<math.h>
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main() {
  long a,b,c,d;
  cin>>a>>b>>c>>d; 
  
  cout<<max(a*b,c*d)<<endl;
}



Measured memory_bytes: 256
S = list(input())
len_S =len(S)

cntA = 0
cntB = 0

# 10101010
for i in range(len_S):
    if i%2==0 and S[i]=="0":
        cntA +=1
    elif i%2==1 and S[i]=="1":
        cntA +=1

# 01010101
for i in range(len_S):
    if i%2==1 and S[i]=="0":
        cntB +=1
    elif i%2==0 and S[i]=="1":
        cntB +=1

print(min(cntA,cntB))


Measured memory_bytes: 3956
/*
 * Author: Anmol Choudhary
 */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nextl cout<<"\n"
#define deb(x) cout<<#x<<"="<<x<<"\n"
#define deb2(x,y) cout<<"["<<#x<<"="<<x<<"] , ["<<#y<<"="<<y<<"]"<<"\n"
const ll mod = 1000000007;
const ll maxn = 500005;
const ll mm = 1e+18;
ll power(ll x, ll y)
{
    ll res = 1;
    x = x % mod;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res;
}
void solve()
{
    int n;
    cin>>n;
    vector<int>v;
    rep1(i,n) v.pb(i);
    vector<int>v1,v2;
    rep1(i,n){
        int x;
        cin>>x;
        v1.pb(x);
    }
    rep1(i,n){
        int x;
        cin>>x;
        v2.pb(x);
    }
    int an1=0;
    int an2=0;
    int x=1;
    do{
        if(v==v1) an1=x;
        if(v==v2) an2=x;
        x++;
    }while(next_permutation(v.beg,v.en));
    int an=abs(an1-an2);
    pr(an);
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        //nextl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <time.h>
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#include <memory.h>
#include <cstdlib>
#include <queue>
#include <iomanip>
#define P pair<int, int>
#define LL long long
#define LD long double
#define PLL pair<LL, LL>
#define mset(a, b) memset(a, b, sizeof(a))
#define rep(i, a, b) for(int i = a; i < b; i++)
#define PI acos(-1.0)
#define random(x) rand() % x
using namespace std;
const int inf = 0x3f3f3f3f;
const LL __64inf = 0x3f3f3f3f3f3f3f3f;
const int MAX = 1e5 + 5;
const int Mod = 1e9 + 7;

int main()
{
    LL a, b, q;
    cin >>a >> b >> q;
    vector<LL> s(a), t(b);
    rep(i, 0, a)   
        cin >> s[i];
    rep(i, 0, b)
        cin >> t[i];
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    rep(i, 0, q){
        LL p;
        cin >> p;
        auto it1 = lower_bound(s.begin(), s.end(), p);
        auto it2 = lower_bound(t.begin(), t.end(), p);
        LL ans = __64inf;
        if(it1 != s.end() && it2 != t.end())
            ans = min(ans, max(*it1, *it2)-p);
        if(it1 != s.begin() && it2 != t.begin())
            ans = min(ans, p - min(*(it1-1), *(it2-1)));
        if(it1 != s.begin() && it2 != t.end())
            ans = min(ans, *it2-*(it1-1)+min(*it2-p, p-*(it1-1)));
        if(it1 != s.end() && it2 != t.begin())
            ans = min(ans, *it1-*(it2-1)+min(*it1-p, p-*(it2-1)));
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 2944
program B081
    implicit none
    integer(8) :: N
    integer(8), allocatable, dimension(:) :: A
    integer(8) :: i, j, sum

    read(5,*) N
    allocate(A(N))
    read(5,*) (A(i), i = 1, N)
    sum = 0

    j = 0
    do while (j == 0)
        do i = 1, N
            if (mod(A(i),2) == 0) then
                A(i) = A(i) / 2
            else
                j = j + 1
            end if


        end do
        if (j == 0) then
            sum = sum + 1
        end if



    end do


    write(6,*) sum




end program B081

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

int main(){
  string S;
  cin >> S;
  int c1 = 0, c2 = 0;
  for(int i=0;i<S.size();i++){
    if(S[i] == '0'){
      c1++;
    }
    else{
      c2++;
    }
  }
  int maxv,minv;
  minv = min(c1,c2);
  cout << 2 * minv << endl;
}


Measured memory_bytes: 512
/*
srt: 2017年05月01日 22時15分42秒
end: 2017年05月01日 23時09分22秒
*/

#include<cstdio>
#include<algorithm>
inline void read(int&r)
{
	register char c;r=0;
	do c=getchar();while(c<'0'||c>'9');
	do r=r*10+c-'0',c=getchar();while(c>='0'&&c<='9');
}

typedef long long ll;

#define x a[i].first
#define y a[i].second
typedef std::pair<int,int> pii;

pii a[200000];

int main()
{
	int n,i,l=1e9,r=1,s=1,t=1e9;read(n);
	for(i=0;i<n;i++)
	{
		read(x),read(y);
		if(x>y)x^=y^=x^=y;
		if(x<l)l=x;
		if(y>r)r=y;
		if(x>s)s=x;
		if(y<t)t=y;
	}

	ll ans=(ll)(s-l)*(r-t),tmp=r-l,now;
	std::sort(a,a+n);
	for(i=0;i<n;i++)
	{
		if(x>t)
		{
			if((now=tmp*(s-t))<ans)ans=now;
			break;
		}
		if((now=tmp*(s-x))<ans)ans=now;
		if(y>s)s=y;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 1664
#include<stdio.h>
#include<iostream>
#include<list>
#include<map>
#include<vector>
#include<algorithm>
#include<string.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << x << endl;
using namespace std;

const int MAX = 81;

int main(){
    int n;
    cin >> n;
    while(n--){
        vector<int> ans;
        string input1, input2;
        int len1, len2, up = 0;
        
        cin >> input1 >> input2;
        len1 = input1.length() - 1;
        len2 = input2.length() - 1;
        reverse(input1.begin(), input1.end());
        reverse(input2.begin(), input2.end());

        rep(i,MAX){
            int add = up;
            if(i <= len1){
                add+= input1[i] - '0';
            }
            if(i <= len2){
                add+= input2[i] - '0';
            }
            if(!(add == 0 && i > len1 && i > len2))
            ans.push_back(add % 10);
            up = add / 10;
            if(i > len1 && i > len2) break;
        }

        if(ans.size() > 80){
            cout << "overflow" << endl;
        }else{
            vector<int>::iterator it;
            it = ans.end();
            while(ans.size() != 0){
                --it;
                cout << *it;
                ans.pop_back();
            }cout << endl;
        }
    }
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d;
int main()
{
    scanf("%lld%lld%lld",&a,&b,&c);
    if (!(a%c)) d=a/c; else d=a/c+1;
    printf("%lld",b/c-d+1);
}

Measured memory_bytes: 256
def main():
    N=int(input())
    AB=[0]*N
    for i in range(N):
        ab=list(map(int,input().split()))
        AB[i]=ab
    AB.sort(key=lambda x:x[1])
    t=0
    flag=True
    for i in range(N):
        t+=AB[i][0]
        if t>AB[i][1]:
            print("No")
            flag=False
            break
    if flag:
        print("Yes")
if __name__=="__main__":
    main()

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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  for(int i=0;i<d-b;i++){
    cout << "U";
  }
  for(int i=0;i<c-a;i++){
    cout << "R";
  }
  for(int i=0;i<d-b;i++){
    cout << "D";
  }
  for(int i=0;i<c-a;i++){
    cout << "L";
  }
  cout << "L";
  for(int i=0;i<d-b+1;i++){
    cout << "U";
  }
  for(int i=0;i<c-a+1;i++){
    cout << "R";
  }
  cout << "DR";
   for(int i=0;i<d-b+1;i++){
    cout << "D";
  }
  for(int i=0;i<c-a+1;i++){
    cout << "L";
  }
  cout << "U";
}

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

int main()
{
	ll a,b,k;
	cin >> a >> b >> k;
	if (b-a+1 <= 2 * k)
	{
		ll temp = a;
		while(temp <= b)
		{
			cout << temp << endl;
			temp++;
		}
	}
	else
	{
		rep(i,k)
		{
			cout << a + i << endl;
		}
		rep(i,k)
		{
			cout << b - k + 1 + i << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;


namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            int N = int.Parse(ReadLine());
            string s = ReadLine();
            int K = int.Parse(ReadLine());
            string ans = "";
            for (int i = 0; i < s.Length; i++)
            {
                if (s[K-1] == s[i])
                {
                    ans += s[i].ToString();
                }
                else
                {
                    ans += "*";
                }
            }
            WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11092
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

int main(void) {
  long N, Z, W;
  cin >> N >> Z >> W;
  vector<long> a(N);
  rep (i, N) cin >> a[i];

  if (N == 1) cout << abs(a[N-1] - W) << endl;
  else cout << max(abs(a[N-1] - W), abs(a[N-2] - a[N-1])) << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque, defaultdict
import heapq
input = sys.stdin.buffer.readline


def dijkstra(adj, start):
    # adj: [[to, cost] * vertices], 0th index must be empty
    dist = [float('inf')] * len(adj)
    dist[start] = 0
    q = []
    heapq.heappush(q, (0, start))
    while q:
        min_dist, v_from = heapq.heappop(q)
        if min_dist > dist[v_from]:
            continue
        v_tos = adj[v_from]
        for v_to, cost in v_tos:
            if min_dist + cost < dist[v_to]:
                dist[v_to] = min_dist + cost
                heapq.heappush(q, (dist[v_to], v_to))
    return dist


def main():
    mod = 10**9+7
    N, M = map(int, input().split())
    s, t = map(int, input().split())
    adj = [[] for _ in range(N+1)]
    for _ in range(M):
        l, r, d = map(int, input().split())
        adj[l].append((r, d))
        adj[r].append((l, d))

    dist = dijkstra(adj, s)
    collision_T = dist[t] / 2 if dist[t] % 2 == 1 else dist[t] // 2
    route = [0] * (N+1)
    route[t] = 1
    que = []
    heapq.heappush(que, (-dist[t], t))
    col_edge = set()
    seen = [0] * (N+1)
    seen[t] = 1
    while que:
        _, v = heapq.heappop(que)
        for u, d in adj[v]:
            if dist[v] == dist[u] + d:
                route[u] = (route[u] + route[v]) % mod
                if dist[u] < collision_T < dist[v]:
                    col_edge.add((u, v))
                elif dist[v] == collision_T:
                    col_edge.add((v, v))
                if not seen[u]:
                    heapq.heappush(que, (-dist[u], u))
                    seen[u] = 1

    #reverse
    route2 = [0] * (N+1)
    route2[s] = 1
    que = []
    heapq.heappush(que, (0, s))
    seen = [0] * (N+1)
    seen[s] = 1
    while que:
        _, v = heapq.heappop(que)
        for u, d in adj[v]:
            if dist[u] == dist[v] + d:
                route2[u] = (route2[u] + route2[v]) % mod
                if not seen[u]:
                    heapq.heappush(que, (dist[u], u))
                    seen[u] = 1

    #print(route)
    #print(route2)

    ans = pow(route[s], 2, mod)
    for u, v in col_edge:
        tmp = (route[v] * route2[u])%mod
        ans = (ans - pow(tmp, 2, mod))%mod
    print(ans)


if __name__=='__main__':
    main()


Measured memory_bytes: 115872
import java.util.Scanner;
import java.util.Stack;

public class Main {


    static class Pair{
        public final int first;
        public final int second;

        public Pair(int first, int second) {
            this.first = first;
            this.second = second;
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Stack<Integer> so = new Stack<Integer>();
        Stack<Pair> ps = new Stack<Pair>();
        int sum = 0;
        char[] chars = null;
        if (sc.hasNextLine()){
            String line = sc.nextLine();
            chars = line.toCharArray();
        }
        for(int i = 0; i < chars.length; i++){
            if(chars[i] == '\\'){
                so.push(i);
            }
            else if(chars[i] == '/' && so.size() > 0){
                int j = so.peek();
                so.pop();
                sum += i - j;
                int a = i - j;//区域面和
                while(ps.size() > 0 && ps.peek().first > j){
                    a += ps.peek().second;
                    ps.pop();
                }
                ps.push(new Pair(j,a));
            }
        }


        Stack<Integer> s = new Stack<Integer>();
        while (ps.size() > 0){
            s.push(ps.peek().second);
            ps.pop();
        }
        System.out.println(sum);
        System.out.print(s.size());
        while (s.size() > 0){
            System.out.print(" " + s.peek());
            s.pop();
        }
        System.out.println();
    }
}



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

int main(){
  int A, B, C;
  int sum = 0;
  cin >> A >> B >> C;
  bool flag = false;
  for(int i=1;i<=B;++i){
    if(C==(A*i)%B) flag = true;
  }
  
  if(flag) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

#define K_MAX 100000
#define INF 1000000

using namespace std;

int H, W;
char S[50][51];

int countMines(int i, int j) {
  int count = 0;
  for (int k = i - 1; k <= i + 1; k++) {
    for (int l = j - 1; l <= j + 1; l++) {
      if (k < 0 || k >= H || l < 0 || l >= W || (k == i && l == j)) {
        continue;
      }
      if (S[k][l] == '#') {
        count++;
      }
    }
  }
  return count;
}

int main() {
  scanf("%d %d", &H, &W);
  for (int i = 0; i < H; i++) {
    scanf("%s", S[i]);
  }

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (S[i][j] == '#') {
        continue;
      }
      S[i][j] = countMines(i, j) + '0';
    }
  }

  for (int i = 0; i < H; i++) {
    printf("%s\n", S[i]);
  }

  return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    
    int n, l;
    cin >> n >> l;
    
    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    
    for (int i = 1; i < n; i++) {
        if (a[i] + a[i +1] >= l) {
            cout << "Possible" << endl;
            for (int j = 1; j < i; j++) {
                cout << j << endl;
            } 
            for (int j = n - 1; j >= i; j--) {
                cout << j << endl;
            }
            break;    
        }
        if (i == n - 1) {
            cout << "Impossible" << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 1280
import sys

n, k = map(int, sys.stdin.readline().split())
r, s, p = map(int, sys.stdin.readline().split())
t = sys.stdin.readline().rstrip()
point = dict([('r', r), ('s', s), ('p', p)])

def hand(opponent):
    if opponent == 'r':
        return 'p'
    elif opponent == 's':
        return 'r'
    elif opponent == 'p':
        return 's'

def main():
    res = 0
    for i in range(k):
        cur = hand(t[i])
        res += point[cur]
        prev = cur
        for j in range(i+k, n, k):
            cur = hand(t[j])
            if cur == prev:
                cur = 'any'
            else:
                res += point[cur]
            prev = cur
    return res

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3444
#include <iostream>

using namespace std;

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


    return 0;
    
}

Measured memory_bytes: 256
from collections import defaultdict, deque


def bfs(start):
    q = deque([start])
    dist = [-1] * N
    dist[start] = 0
    while q:
        v = q.popleft()
        for nv, nw in g[v]:
            if dist[nv] >= 0:
                continue
            dist[nv] = (dist[v] + nw) % 2
            q.append(nv)
    return dist


N, *UVW = map(int, open(0).read().split())
g = defaultdict(set)

ans = [0] * N
for u, v, w in zip(*[iter(UVW)] * 3):
    u -= 1
    v -= 1
    g[u].add((v, w))
    g[v].add((u, w))
print("\n".join(map(str, bfs(0))))


Measured memory_bytes: 78652
from collections import deque

time = 0
finished = 0
n,q = map(int,input().split())


def rotate(A):
    global time,finished
    b = A.popleft()
    if b[1] - q > 0:
        b[1] -= q
        time += q
        A.append(b)
    else:
        time += b[1]
        finished += 1
        print(b[0],time)


def main():    
    order = deque([])
    for _ in range(n):
        tmp = list(input().split())
        tmp[1] = int(tmp[1])
        order.append(tmp)

    ##print("-----")
    while finished < n:
        rotate(order)
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 14576
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,s,n) for(int i = s; i < (int)(n); i++)

int main() {
  ll n;
  cin >> n;
  cout << n*(n-1)/2 << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const int N = 100;

int n;

int f[N][10], p[N][11];

ll ans = -INF;

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> f[i][j];
        }
    }

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 11; ++j) {
            cin >> p[i][j];
        }
    }

    for (int i = 1; i < (1 << 10); i++) {
        int sim[n] = { 0 };
        for (int j = 0; j < 10; j++) {
            if (i & (1 << j)) {
                for (int k = 0; k < n; k++) {
                    if (f[k][j]) sim[k]++;
                }
            }
        }

        ll cur = 0;
        for (int j = 0; j < n; ++j) cur += p[j][sim[j]];
        ans = max(ans, cur);
    }
    cout << ans;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;

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

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int N, M; std::cin >> N >> M;
  std::vector<std::vector<int>> G(N);
  rep(i,M) {
    int A, B; std::cin >> A >> B; A--,B--;
    G[A].push_back(B);
    G[B].push_back(A);
  }
  
  std::vector<int> used(N, -1);
  std::queue<int> q;
  q.push(0);
  used[0] = 0;
  while(!q.empty()) {
    int cur = q.front(); q.pop();
    for(auto&& next : G[cur]) {
      if ( used[next] != -1 ) continue;
      used[next] = cur;
      q.push(next);
    }
  }

  bool check = true;
  rep(i,N) if ( used[i] == -1 ) check = false;
  if ( !check ) std::cout << "No" << std::endl;
  else {
    std::cout << "Yes" << std::endl;
    for(int i=1; i<N; i++) std::cout << used[i]+1 << std::endl;
  }

  return 0;
}



Measured memory_bytes: 10264
// Pana2020 B
// 2020.3.14 bal4u

#include <stdio.h>

typedef long long ll;

int main()
{
	int H, W;;

	scanf("%d%d", &H, &W);
	if (H == 1 || W == 1) puts("1");
	else printf("%lld\n", ((ll)H*W+1)/2);
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
int main(void) {
	int a,b,c,tmp;
	scanf("%d %d %d",&a,&b,&c);
	if(a>b){
        tmp=a;
        a=b;
        b=tmp;
	}
	if(b>c){
		tmp=b;
		b=c;
		c=tmp;
	}
	if(a>b){
		tmp=a;
		a=b;
		b=tmp;
	}
	printf("%d %d %d\n",a,b,c);
	return 0;
}

Measured memory_bytes: 596