akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

constexpr int SENTINEL = 1000000001;
int cnt = 0;

void Merge(std::vector<int> &S, int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    std::vector<int> L, R;
    for (auto i=0; i<n1; ++i) L.push_back(S[left+i]);
    for (auto i=0; i<n2; ++i) R.push_back(S[mid+i]);
    L.push_back(SENTINEL);
    R.push_back(SENTINEL);
    int i{0}, j{0};
    for (auto k=left; k<right; ++k) {
        if (L[i] <= R[j]) {
            S[k] = L[i];
            ++i;
            ++cnt;
        } else {
            S[k] = R[j];
            ++j;
            ++cnt;
        }
    }
}

void MergeSort(std::vector<int> &S, int left, int right) {
    if ((left+1) < right) {
        int mid = (left + right) / 2;
        MergeSort(S, left, mid);
        MergeSort(S, mid, right);
        Merge(S, left, mid, right);
    }
}

int main() {
    int n, temp;
    std::cin >> n;
    
    std::vector<int> S;
    for (auto i=0; i<n; ++i) {
        std::cin >> temp;
        S.push_back(temp);
    }
    
    MergeSort(S, 0, n);
    for (auto i=0; i<n; ++i) {
        std::cout << S[i];
        if (i != (n-1)) 
            std::cout << " ";
        else 
            std::cout << std::endl;
    }
    std::cout << cnt << std::endl;
}


Measured memory_bytes: 7752
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_132
{
    class B
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            int[] vals = ReadInts();

            int cnt = 0;
            for(int i = 0; i < n - 2; i++)
            {
                int[] vs = new int[3] { vals[i], vals[i + 1], vals[i + 2] };
                Array.Sort(vs);
                if (vs[1] == vals[i + 1]) cnt++;
            }

            WriteLine(cnt);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11220
w, h, n = map(int, input().split())
c = []
for i in range(n):#h:高さ
    c.append([int(m) for m in input().split()])

sx = [0, w]
sy = [0, h]
for i in range(n):
    if c[i][2] == 1:
        if sx[0] < c[i][0]:
            sx[0] = c[i][0]
    elif c[i][2] == 2:
        if sx[1] > c[i][0]:
            sx[1] = c[i][0]
    elif c[i][2] == 3:
        if sy[0] < c[i][1]:
            sy[0] = c[i][1]
    elif c[i][2] == 4:
        if sy[1] > c[i][1]:
            sy[1] = c[i][1]
if sx[1] <= sx[0] or sy[1] <= sy[0]:
    print(0)
else:
    print((sx[1] - sx[0]) * (sy[1] - sy[0]))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
//#define debug 1

const long MAXN=1010;
char board[MAXN][MAXN];
int dis[MAXN][MAXN];
bool book[MAXN][MAXN];
int h,w,ch,cw,dh,dw;

const int dx[25]={-2,-2,-2,-2,-2,-1,-1,-1,-1,-1,0,0,0,0,1,1,1,1,1,2,2,2,2,2},dy[25]={-2,-1,0,1,2,-2,-1,0,1,2,-2,-1,1,2,-2,-1,0,1,2,-2,-1,0,1,2};
const int ddx[4]={-1,0,0,1},ddy[4]={0,-1,1,0};

struct node{
	int x,y;
};	deque<node> q;
queue<node> q_zero;

bool judge(int x,int y) {
	return x>=1 && x<=h && y>=1 && y<=w;
}

int main() {
	memset(dis,0x3f,sizeof(dis));
	cin>>h>>w>>ch>>cw>>dh>>dw;
	int i,j,k;
	
	for(i=1;i<=h;++i)
		for(j=1;j<=w;++j) {
			board[i][j]=getchar();
			while(board[i][j]!='.' && board[i][j]!='#')
				board[i][j]=getchar();
		}
	
	dis[ch][cw]=0;
	q.push_back((node){ch,cw});
	node top,top_zero;
	while(!q.empty()) {
		top=q.front();
		#ifdef debug
			printf("NODE %d %d\n",top.x,top.y);
		#endif
		q.pop_front();
		if(top.x==dh && top.y==dw) break;
		if(book[top.x][top.y]) continue;
		book[top.x][top.y]=1;
		
		q_zero.push(top);
		while(!q_zero.empty()) {
			top_zero=q_zero.front();
			q_zero.pop();
			for(k=0;k<4;++k)
				if(judge(top_zero.x+ddx[k],top_zero.y+ddy[k]) && book[top_zero.x+ddx[k]][top_zero.y+ddy[k]]==0
				&& dis[top_zero.x+ddx[k]][top_zero.y+ddy[k]]>dis[top.x][top.y] && board[top_zero.x+ddx[k]][top_zero.y+ddy[k]]=='.') {
					dis[top_zero.x+ddx[k]][top_zero.y+ddy[k]]=dis[top.x][top.y];
					q_zero.push((node){top_zero.x+ddx[k],top_zero.y+ddy[k]});
					q.push_front((node){top_zero.x+ddx[k],top_zero.y+ddy[k]});
				}
		}
		
		for(k=0;k<24;++k)
			if(judge(top.x+dx[k],top.y+dy[k]) && book[top.x+dx[k]][top.y+dy[k]]==0
			&& dis[top.x+dx[k]][top.y+dy[k]]>dis[top.x][top.y]+1 && board[top.x+dx[k]][top.y+dy[k]]=='.') {
				dis[top.x+dx[k]][top.y+dy[k]]=dis[top.x][top.y]+1;
				q.push_back((node){top.x+dx[k],top.y+dy[k]});
			}
	}
	
	if(dis[dh][dw]==0x3f3f3f3f)
		cout<<"-1"<<endl;
	else cout<<dis[dh][dw]<<endl;
	return 0;
}

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

using namespace std;

int main() {
	int n; cin >> n;
	vector<int> d(n);
	for(int i = 0; i < n; i++) {
		cin >> d[i];
	}
	sort(d.begin(), d.end(), greater<int>());
	int ans = 1;
	for(int i = 0; i < n-1; i++){
		if(d[i] != d[i+1]) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}

const string YES = "Possible";
const string NO = "Impossible";

void solve(long long N, long long L, std::vector<long long> a){
  bool f=false;
  ll first=-1;
  REP(N-1){
    if(a[i]+a[i+1]>=L){
      f=true;
      first=i;
      break;
    }
  }
  if(f==false){
    cout<<NO<<endl;
    return;
  }
  vector<ll> ans;
  ans.push_back(first);
  Rev(i,first){
    ans.push_back(i);
  }
  For(i,N-first-1-1){
    ans.push_back(i+first+1);
  }
  reverse(ans.begin(),ans.end());
  cout<<YES<<endl;
  REP(ans.size())++ans[i];
  copy(ans.begin(),ans.end(),ostream_iterator<ll>(cout,"\n"));
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long L;
    scanf("%lld",&L);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, L, std::move(a));
    return 0;
}


Measured memory_bytes: 2548
#pragma region Header
#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#define IFD(...)
#ifndef NDEBUG
#define NDEBUG
#endif
#endif
#include <utility>
#include <cstdint>
#include <cmath>
#include <cassert>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#include <functional>
#include <algorithm>
#include <numeric>
#include <stdexcept>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <boost/hana/functional/fix.hpp>
using boost::hana::fix;
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repd(i, n) for (int i = (n)-1; i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define FORD(i, b, a) for (int i = (b); i >= (a); --i)
template <typename T>
int SZ(T const &x)
{
    return static_cast<int>(x.size());
}
template <class T>
bool chmax(T &a, T const &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, T const &b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

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

    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    rep(i, n)
    {
        cout << s[i] << t[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3656
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		String ans = "";
		char[] alphabet = "abcdefghijklmnopqrstuvwxyz".toCharArray();
		if(n<=26) {
			ans = Character.toString(alphabet[(int)n-1]) + ans; 
		}
		else {
			while(n>26) {
				long a = n%26;
				int b = (int) a;
				n=n/26;
				if(b!=0) {
					ans = Character.toString(alphabet[b-1]) + ans;
				}
				else {
					ans = Character.toString(alphabet[25]) + ans;					
					n--;
				}
				
			}
			if(n<=26) {
				ans = Character.toString(alphabet[(int)n-1]) + ans; 
			}
		}
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 39308
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		String s = "NG";

		for(int i = 0; i <= B - A; i ++){
			int x = A + i;
			if(x % K == 0){
			s = "OK";
			break;
			}
		}

		System.out.println(s);
	}
}

Measured memory_bytes: 35692
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
template< int id > struct CompTupleBy
{
  template<class T> 
  bool operator()( const T& a, const T& b ) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};

using namespace std;

int main(){
    int k,a,b;
    cin >> k >> a >> b;
    bool OK = false;
    for (int i=a;i<=b;i++){
        if (i%k == 0){
            OK = true;
        }
    }
    if (OK== true){
        cout << "OK" << endl;
    }else{
        cout << "NG" << endl;
     }


}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int MOD = 1e9+7,H,W;
char s[1005][1005];
int dp[1005][1005];
int move(int r,int d){
    if(s[r][d]=='#' || r==H || d == W)
        return 0;
    if(r== H-1 && d == W-1)
        return 1;
    if(dp[r][d]!=-1)
        return dp[r][d];
    return dp[r][d] = (move(r+1,d)+ move(r,d+1))%MOD;
}
int main() {
    scanf("%d%d",&H,&W);
    for(int i=0;i<H;++i)
        scanf("%s",s[i]);
    memset(dp,-1,sizeof dp);
    printf("%d",move(0,0));
}

Measured memory_bytes: 8732
#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 FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;
const long double EPS = 1e-10;

struct City {
  int p, y, idx;

  bool operator < (const City &c) const {
    return (p == c.p ? y < c.y : p < c.p);
  }
};

int getketa(int n) {
  if (n == 0) return 1;
  int res = 0;
  while (n > 0) {
    res++;
    n /= 10;
  }
  return res;
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<City> c(m);
  rep(i, m) {
    City x;
    cin >> x.p >> x.y;
    x.idx = i;
    c[i] = x;
  }

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

  vector<pair<int, int>> ans(m);
  int pre = 0, cnt = 1;
  rep(i, m) {
    ans[c[i].idx].first = c[i].p;
    if (pre != c[i].p) {
      pre = c[i].p;
      cnt = 1;
    }
    ans[c[i].idx].second = cnt++;
  }

  rep(i, m) {
    int k1 = getketa(ans[i].first);
    int k2 = getketa(ans[i].second);

    rep(i, 6 - k1) cout << 0;
    cout << ans[i].first;
    rep(i, 6 - k2) cout << 0;
    cout << ans[i].second << endl;
  }


  


  
  return 0;
}

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

int main(void){
  char str[1024],*p;
  int flg[2]={0};

  scanf("%s",str);
  for(p=str;*p!='\0';p++){
    if(*p=='C') flg[0]=1;
    if(flg[0]==1 && *p=='F') flg[1]=1;
  }
  puts((flg[0]==1 && flg[1]==1)?"Yes":"No");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h> 
using namespace std; 
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for (int i = 0; i < (n); ++i)

int main(void) {
    io;
    int n; cin >> n;
    vector<int> vec(n);
    int sum = 0;
    rep(i,n) {
        cin >> vec[i];
        sum += vec[i];
    }
    int m; cin >> m;
    vector<int> p(m);
    vector<int> x(m);
    rep(i,m) cin >> p[i] >> x[i];

    rep(i,m) {
        int res = sum;
        res += x[i] - vec[p[i]-1];
        cout << res << "\n";
    }
    return 0;
}



Measured memory_bytes: 3536
N,M=map(int,input().split())
A=[0]*M
day=0
A= [int(i) for i in input().split()]
for cnt in range(M):
  day+=A[cnt]
  if day>N:
    ans=-1
    break
ans=N-day
if ans<0:
  print("-1")
else:
  print(ans)

Measured memory_bytes: 9888
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

a,b,c,x,y = iim()

print(min(a*x+b*y,2*y*c+max(x-y,0)*a,2*x*c+max(y-x,0)*b))


Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
#define NOTFOUND -100
int counter(int *,int *);
int linearSearch(int [],int);
int n=0,m=0;
int main(){
  //int *p,*q;
  int cnt=0,key=0,i=0,p[10000],q[500];
    scanf("%d",&n);
    //p = (int *)malloc(n*sizeof(int));
    for(i=0;i<n;i++)scanf("%d",&p[i]);
    scanf("%d",&m);
    //q = (int *)malloc(m*sizeof(int));
    for(i=0;i<m;i++)scanf("%d",&q[i]);
	/*
	for(i=0;i<m;i++){ 
	 if(linearSearch(p,q[i])){
		printf("q[%d] cnt :%d\n",i,cnt);
		cnt++;
	 } 
	}
	*/
	i=0;
	while(i<m){
		if((linearSearch(p,q[i])) != NOTFOUND) cnt++;
		i++;
	}
    //cnt = counter(&p,&q);
    printf("%d\n",cnt);
    return 0;
}

int linearSearch(int p[],int key){
		int j=0;
		//la :p
		p[n] = key;
		//printf("key = %d\n",p[n]);
		while(p[j] != key){
			//printf("p[%d] = %d\n",j,p[j]);
			j++;
			if(j == n) return NOTFOUND;
		}
		return j;		
}

/*
int counter(int *la,int *sm){
  int i,cnt=0,j;
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      if(la[i] == sm[j]) cnt++;
    }
  }
  return cnt;
}
*/


Measured memory_bytes: 2108
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int A = 0;
		int B = 0;
		int result = 0;
		int[] rs = new int[1000];
		for(int i = 0; i < N; i++) {
			A = scan.nextInt();
			B = scan.nextInt();
			result += B - A;
		}
		System.out.println(result + N);
		scan.close();
	}
}


Measured memory_bytes: 25572
#include<bits/stdc++.h>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++i)
using namespace std;

template <typename tn> void read (tn & a) {
	tn x = 0, f = 1; char c = getchar();
	while (c < '0' || c > '9'){ if (c == '-') f = -1; c = getchar(); }
	while (c >= '0' && c <= '9'){ x = x * 10 + c - '0'; c = getchar(); }
	a = f == 1 ? x : -x;
}

const int MAXN = 8100;
int n;
ll fx[MAXN], fy[MAXN], sx, sy;
ll dp[2][MAXN + MAXN];
int s[MAXN];
int x, y, tfx, tfy;

void init() {
//	cerr<<"??\n";
	char c = getchar();
//	cerr<<"  c = "<<c<<"\n";
	while (c != 'F' && c != 'T') {
		c = getchar();
//	cerr<<"  c = "<<c<<"\n";
	}
	n = 0;
//	cerr<<"??\n";
	while (c == 'F' || c == 'T') {
		s[++n] = c == 'F' ? 1 : 0;
		c = getchar();
	}
	read(x); read(y);
}

int main() {
//	freopen("in.txt","r",stdin);
	
//	read(n);
//	cerr<<"n = "<<n<<"\n";
//	freopen("out.txt","w",stdout);
////	string str;
//	scanf("%s",str);
//	n=strlen(str);
//	cerr<<" n = "<<n<<"\n";

//	string s;
//	cin >> s;
//	cerr<<s<<"\n";
//	cin >> s;
//	cerr<<s<<"\n";

	init();
	int tf = 1; sx = sy = 0;
	rep(i, 0, n) {
		int j = i;
		while (j < n && s[j + 1]) ++j;
		int l = j - i;
		if (tf) { fx[++sx] = l; if (l != 0) tfx = 1; }
		else { fy[++sy] = l; if (l != 0) tfy = 1; }
		tf = 1 - tf; i = j;
	}
	dp[1][fx[1] + MAXN] = 1;
	rep(i, 2, sx) {
		int k = i % 2;
		rep(j, 0, MAXN + MAXN - 1) dp[k][j] = 0;
		rep(j, 0, MAXN + MAXN - 1) {
			if (j - fx[i] >= 0) dp[k][j] |= dp[1 - k][j - fx[i]];
			if (j + fx[i] < MAXN + MAXN) dp[k][j] |= dp[1 - k][j + fx[i]];
		}
	}
	bool tx = dp[sx % 2][x + MAXN] || (tfx == 0 && x == 0) ? 1 : 0;
	rep(j, 0, MAXN + MAXN - 1) dp[1][j] = 0;
	dp[1][MAXN-fy[1]] = 1; dp[1][fy[1] + MAXN] = 1;
	rep(i, 2, sy) {
		int k = i % 2;
		rep(j, 0, MAXN + MAXN - 1) dp[k][j] = 0;
		rep(j, 0, MAXN + MAXN - 1) {
			if (j - fy[i] >= 0) dp[k][j] |= dp[1 - k][j - fy[i]];
			if (j + fy[i] < MAXN + MAXN) dp[k][j] |= dp[1 - k][j + fy[i]];
		}
	}
	bool ty = dp[sy % 2][y + MAXN] || (tfy == 0 && y == 0) ? 1 : 0;
	if (tx && ty) printf("Yes\n"); else printf("No\n");
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
using namespace std;

typedef long long ll;
#define modulo 1000000007 // 10^9 + 7
#define MAX 1000000000 // 10^9


int main() {
	int c[9];
	for (int i = 0; i < 9; i++) cin >> c[i];

	int a[3];
	int b[3];

	a[0] = 0;
	for (int i = 0; i < 3; i++) b[i] = c[i] - a[0];
	a[1] = c[3] - b[0];
	a[2] = c[6] - b[0];

	bool ans = true;

	if (a[1] + b[1] != c[4]) ans = false;
	if (a[2] + b[1] != c[7]) ans = false;
	if (a[1] + b[2] != c[5]) ans = false;
	if (a[2] + b[2] != c[8]) ans = false;

	if (ans) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
	string a;
	cin>>a;
	int g=0;
	for(int i=1;i<=a.length()-1;i++)
		if(a[i]!=a[i-1])
			g++;
	cout<<g<<endl;
	return 0;
}

Measured memory_bytes: 512
n=int(input())
a_1,a_2 = [list(map(int,input().split())) for i in range(2)]

output = 0
for i in range(1,n+1):
    tmp = sum(a_1[:i]) + sum(a_2[i-1:])
    if tmp > output:
        output = tmp

print(output)

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

int main() {

    int N;
    cin >> N;
    vector<int> numbers(N);
    char c, d;
    int count = 1;
    for (int i=0;i<N;i++){
        if(i==0){
            cin >> c;
        } else{
            cin >> d;
            if(c!=d){
                count += 1;
                c = d;
            }
        }
    }
    cout << count;

}

Measured memory_bytes: 640
#include<cstdio>
using namespace std;

const int MAX = 2000 + 10;

int rec[MAX][MAX];
char arr[MAX];

int sa[MAX][MAX];
int sb[MAX][MAX];
int sc[MAX][MAX];

int main() {

    int n, m, q;
    scanf("%d %d %d", &n, &m, &q);

    for(int i = 0 ; i < n ; i++) {
        scanf("%s", arr);
        for(int j = 0 ; j < m ; j++) {
            if(arr[j] == '1') rec[i+1][j+1] = 1;
            else rec[i+1][j+1] = 0;
        }
    }

    for(int i = 1 ; i <= n ; i++) {
        for(int j = 1 ; j <= m ; j++) {
            if(rec[i][j] == 1 && rec[i+1][j] == 1) {
                sb[i][j] = 1;
            }
            if(rec[i][j] == 1 && rec[i][j+1] == 1){
                sc[i][j] = 1;
            }
        }
    }

    for(int i = 1 ; i <= n ; i++) {
        for(int j = 1 ; j <= m ; j++) {
            sa[i][j] = rec[i][j] + sa[i-1][j] + sa[i][j-1] - sa[i-1][j-1];
            sb[i][j] = sb[i][j] + sb[i-1][j] + sb[i][j-1] - sb[i-1][j-1];
            sc[i][j] = sc[i][j] + sc[i-1][j] + sc[i][j-1] - sc[i-1][j-1];
        }
    }
    
    while(q--) {
        int x1, y1, x2, y2;
        scanf("%d %d %d %d", &x1, &y1, &x2, &y2);

        int ca = sa[x2][y2] - sa[x2][y1-1] - sa[x1-1][y2] + sa[x1-1][y1-1];
        int cb = sb[x2-1][y2] - sb[x2-1][y1-1] - sb[x1-1][y2] + sb[x1-1][y1-1];
        int cc = sc[x2][y2-1] - sc[x2][y1-1] - sc[x1-1][y2-1] + sc[x1-1][y1-1];
        printf("%d\n", ca-cb-cc);
    }

    return 0;
}

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

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;

int main()
{
    int n=5;
    int res=0;

    int t[5];    
    int m=10;
    int last_i;
    for(int i=0;i<n;i++){
        cin >> t[i];
        if(m>t[i]%10 && t[i]%10!=0){
            m=t[i]%10;
            last_i=i;
        }
    }
    for(int i=0;i<n;i++){
        if(i==last_i || t[i]%10==0){
            res += t[i];
        } else {
            res += t[i] + (10-t[i]%10);
        }
    }
    p(res)
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string.h>
#include <algorithm>
using namespace std;

int main()
{
    long long n, longest, shortest, plans;
    cin >> n >> shortest >> longest;
    if(longest < shortest) cout << "0" << endl;
    else if(longest != shortest && n == 1) cout << "0" << endl;
    else{
        plans = (shortest + longest * (n - 1)) - (longest + shortest * (n - 1)) + 1;
        cout << plans << endl;
    }
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int main() {
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for (int i = 0; i < 3; i++) {
        if (s.at(i) == t.at(i)) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <cstring>

#define MAX 100005

using namespace std;

vector<int> stones;

int N, K;

int dp[MAX];

int frog(int n, int k);

int main() {
    scanf("%d %d", &N, &K);
    for (int i = 0; i < N; ++i) {
        int x;
        scanf("%d", &x);
        stones.push_back(x);
    }

    memset(&dp, -1, sizeof dp);

    printf("%d", frog(0, K));
    return 0;
}

int frog(int n, int k)
{
    if(n > N -1) return 100000;
    if(n == N -1) return 0;
    if(dp[n]!= -1)
        return dp[n];

    int tmp = abs(stones[n] -stones[n+1]) + frog(n + 1, k);
    for (int i = 2; i <= k; ++i) {
        tmp = min(tmp, abs(stones[n] -stones[n+i]) + frog(n + i, k));
    }
    dp[n] = tmp;
    return dp[n];
}

Measured memory_bytes: 8952
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int a,b,c,d;cin>>a>>b>>c>>d;
    cout<<min(a,b)+min(c,d)<<endl;
}

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

using namespace std;

const int maxn = 105;

int b[maxn];

int main() {
	int n;
	cin >> n;
	int ans = 0;
	for(int i = 0 ; i < n ; i++)cin >> b[i];
	for(int i = 0 ; i < n ; i++) {
		for(int j = i + 1 ; j < n ; j++) {
			ans += b[i] * b[j];
		}
	}	
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
ary = [0] * 1000000
for i in range(1, 1000 + 1):
    for j in range(2, 1000 + 1):
        val = i ** j
        # print(val)
        if val > 1000:
            break
        ary[val] += 1
x = int(input())
for i in range(x + 1):
    index = x - i
    if ary[index] > 0:
        break
print(index)

Measured memory_bytes: 16612
n = int(input())
shops = {}
for i in range(n):
  s, p = input().split()
  shops.setdefault(s, []).append((int(p), i+1))

sorted_shops = sorted(shops.items(), key=lambda x: x[0])

for s, p in sorted_shops:
  for shop in sorted(p, key=lambda x: x[0], reverse=True):
    print(shop[1])

Measured memory_bytes: 3060
#include<stdio.h>
#include<string>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<bitset>

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    std::map<pair<long long int,long long int>,int> m;
    int n;
    long long int x[55],y[55];
    long long int dx,dy;
    scanf("%d",&n);
    int ans=n;
    REP(i,n)scanf("%lld%lld",&x[i],&y[i]);
    REP(i,n)REP(j,n){
        if(i!=j){
            dx=x[i]-x[j];
            dy=y[i]-y[j];
            if(dx<0){
                dx*=-1;
                dy*=-1;
            }
            if(dx==0 && dy<0){
                dy*=-1;
            }
            if(m.find(make_pair(dx,dy))!=m.end())m[make_pair(dx,dy)]=m[make_pair(dx,dy)]+1;
            else m.emplace(make_pair(make_pair(dx,dy),1));
        }
    }
    int max=0;
    for(auto i=m.begin();i!=m.end();++i){
        if(max<i->second)max=i->second;
    }
    printf("%d\n",ans-max/2);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> dP;

const int INF = 100000000;
const double EPS = 1e-10;

int d[100001];
int dsum[100001];

int main(){
	//freopen("test.txt", "r", stdin);
	while(1){
		int n;
		cin >> n;
		if(!n) break;
		int cnt = 0;
		rep(i, n/4){
			int m;
			cin >> m;
			cnt += m;
		}
		cout << cnt << endl;
	}

	return 0;
}

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

using namespace std;

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

#define INF 2<<29
#define F first
#define S second

int main(){
  string s;
  bool flg[26];
  cin>>s;

  fill(flg,flg+26,true);
  
  for(int i=0;i<s.size();i++){
    flg[s[i]-'a']=false;
  }

  for(int i=0;i<26;i++){
    if(flg[i]){
      printf("%c\n",'a'+i);
      break;
    }
    if(i==25) printf("None\n");
  }

  return (0);
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define All(obj) (obj).begin(),(obj).end()

using namespace std;


int main() {
	speed;
	int d;
	cin >> d;
	if (d == 22)cout << "Christmas Eve Eve Eve";
	if (d == 23)cout<<"Christmas Eve Eve";
	if (d == 24)cout << "Christmas Eve";
	if (d == 25)cout << "Christmas";
	ed;
	return 0;
}


Measured memory_bytes: 256
a, b, c, x, y = [int(i) for i in input().split(" ")]

price = a*x + b*y
a_num = x
b_num = y

while True:
	if a_num > 0:
		a_num -= 1
		next_price = price - a
	if b_num > 0:
		b_num -= 1
		next_price = next_price - b

	next_price = next_price + c*2
	if next_price < price:
		price = next_price
	else:
		print(price)
		break

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

typedef long long ll;

int main()
{
    int q;
    int i;
    cin >> q;
    vector<int> l(q);
    vector<int> r(q);
    for(i = 0;i < q;++i){
        cin >> l.at(i) >> r.at(i);
    }
    vector<bool> era(1e5+1,true);
    era.at(0) =false;
    era.at(1) = false;
    int j;
    for(i = 2; i <= 1e5;++i){
        if(era.at(i)){
            for(j = 2*i;j <= 1e5;j += i){
                era.at(j) = false;
            }
        }
    }
    vector<int> ans(1e5+1,0);
    int temp_ans = 0;
    for(i = 3;i <= 1e5;i += 2){
        if(era.at(i) && era.at((i+1)/2)){
            ++temp_ans;
        }
        ans.at(i) = temp_ans;
    }
    for(i = 0;i < q ;++i){
        if(l.at(i) == 1){
            cout << ans.at(r.at(i)) - ans.at(l.at(i)) << endl;
        }else{
            cout << ans.at(r.at(i)) - ans.at(l.at(i)-2) << endl;
        }   
    }
    return 0;
}

Measured memory_bytes: 1920
/**
 * @author: Mackenzie
**/
#include <bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;

int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    int h,w,n;
    cin>>h>>w>>n;
    cout<<(n+max(h,w)-1)/max(h,w)<<endl;
    return 0;
}

Measured memory_bytes: 256
h,w,k = list(map(int,input().split()));arr = [[int(i) for i in input()] for _ in range(h)]

from itertools import product
ans = 2000

for i in product([True,False],repeat=(h-1)):
    cut = sum(i)
    splits = [0] * (cut+1)
    splits[0] = arr[0][:]
    tmp = 0
    div = cut
    for j in range(1,h):
        if i[j-1]:
            tmp += 1
            splits[tmp] = arr[j][:]
        else:
            splits[tmp] = [splits[tmp][idx]+arr[j][idx] for idx in range(w)]
    
    check = 0
    for j in splits:
        check = max(check,max(j))
    if check > k:
        break
    count = [splits[j][0] for j in range(cut+1)]
    
    for j in range(1,w):
        addarr = [count[idx]+splits[idx][j] for idx in range(cut+1)]
        if max(addarr) > k:
            div += 1
            count = [splits[idx][j] for idx in range(cut+1)]
        else:
            count = addarr[:]
    ans = min(ans,div)
        
print(ans)

Measured memory_bytes: 3316
//Echo
#include <iostream>
#include <string>
using namespace std;
int main() {
	int n;
	string s;
	cin >> n;
	cin >> s;
	if (n & 1 != 0) {
		cout << "No" << endl;
		return 0;
	}
	else {
		for (int i = 0; i < n / 2; i++) {
			if (s[i] != s[i + n/2]) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
int n,m;
vector<int>vec[15];
int main(){	
	cin>>n>>m;
	rep(i,n){
		int a;
		rep(j,m){ cin >> a; vec[i].pb(a) ;}
	}
	int ans = 0;
	rep(i,n) for(int j=i+1;j<n;j++){
		int x = 0;
		rep(k,m){
			x += (vec[i][k]-vec[j][k])*(vec[i][k]-vec[j][k]);
		}
		rep(w,1000){
			if(w*w == x) ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
 
 
const int N=200000+10;
int Father[N];
 
int find(int x){
    return Father[x]==x ? x:Father[x]=find(Father[x]);
}
 
void Union(int x,int y){
    int fx=find(x),fy=find(y);
    if(fx!=fy){
        Father[fx]=fy;
    }    
}
 
struct TnT{
    int x;
    int y;
    int id;
}T[N];
 
struct side{
    int u;
    int v;
    int d;
}S[N];
 
bool cmpx(TnT a,TnT b){
    return a.x<b.x;    
}
 
bool cmpy(TnT a,TnT b){
    return a.y<b.y;    
}
 
bool cmpd(side a,side b){
    return a.d<b.d;    
}
 
int main(){
    int n,m=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>T[i].x>>T[i].y;
        T[i].id=i;
        Father[i]=i;
    }
    
    sort(T+1,T+1+n,cmpx);
    for(int i=1;i<n;i++){
        S[m].u=T[i].id;
        S[m].v=T[i+1].id;
        S[m].d=T[i+1].x-T[i].x;
        m++;
    }
    
    sort(T+1,T+1+n,cmpy);
    for(int i=1;i<n;i++){
        S[m].u=T[i].id;
        S[m].v=T[i+1].id;
        S[m].d=T[i+1].y-T[i].y;
        m++;
    }
    
    long long ans=0;
    sort(S,S+m,cmpd);
    for(int i=0;i<m;i++){
        if(find(S[i].u)!=find(S[i].v)){
            ans+=S[i].d;
            Union(S[i].u,S[i].v);
        }
    }
    
    cout<<ans<<endl;
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  rep(i, n) cin >> c[i];
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());
  ll l = 0, r = 0;
  ll ans = 0;
  for(int i = 0; i < n; ++i) {
    while(l < n && a[l] < b[i]) ++l;
    while(r < n && b[i] >= c[r]) ++r;
    ans += l * (n - r);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1408
#include<stdio.h>
int main(){
  char s[4],c[4];
  scanf("%s %s",&s,&c);
  if(s[0] == c[2] && s[1] == c[1] && s[2] == c[0]){
    printf("YES\n");
  }else{
    printf("NO\n");
  }
  return 0;
}

Measured memory_bytes: 128
//
// Created by yamunaku on 2019/12/22.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

struct state{
    int x;
    int c;
    int d;
};

int main(){
    // CFS;
    int n, u, v;
    cin >> n >> u >> v;
    u--,v--;
    mti e(n);
    int x, y;
    rep(i, n - 1){
        cin >> x >> y;
        e[x - 1].push_back(y - 1);
        e[y - 1].push_back(x - 1);
    }
    queue<state> q;
    q.push({v, 1, 0});
    q.push({u, 0, 0});
    vector<int> dist(n, -1);
    vector<int> dist2(n, -1);
    dist[u] = 0;
    dist2[v] = 0;
    int ans = 0;
    while(!q.empty()){
        auto now = q.front();
        q.pop();
        if(now.c == 0){
            for(auto &nx:e[now.x]){
                if(dist[nx] == -1 && dist2[nx] == -1){
                    dist[nx] = now.d + 1;
                    q.push({nx, 0, now.d + 1});
                }
            }
        }else{
            if(dist[now.x] != -1){
                ans = max(ans, now.d-1);
            }
            for(auto &nx:e[now.x]){
                if(dist2[nx] == -1){
                    dist2[nx] = now.d + 1;
                    q.push({nx, 1, now.d + 1});
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6784
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(void){
	
  	char s[11],buf[4];
  	long long int ans=9999999999,sub;	
  	int i,len;	
  
	scanf("%s",s);
  	len = strlen(s);
  
  	for(i=0;i<=len-3;i++){
    	strncpy(buf,s+i,3);
      	sub = abs(atoi(buf) - 753);
    	if(ans > sub){
          ans = sub;
        }
    }
  	
  	printf("%lld",ans);
  
  
	return 0;
}






Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

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

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
ll digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
ll countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}


int main() {
	IOS;
	int x, a, b;
	cin >> x >> a >> b;
	if (abs(a - x) > abs(b - x))cout << 'B' << endl;
	else cout << 'A' << endl;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a,b,c,d;cin>>a>>b>>c>>d;
  if(a+b==c+d){
    cout<<"Balanced"<<endl;
  }
  else if(a+b>c+d){
    cout<<"Left"<<endl;
  }
  else{
    cout<<"Right"<<endl;
  }
  return 0;
}

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            while (true)
            {
                string[] input = Console.ReadLine().Split(' ');
                int H = int.Parse(input[0]);
                int W = int.Parse(input[1]);

                if (H == 0 && W == 0) break;

                string[] map = new string[H];
                bool[,] isVisit = new bool[H, W];

                for (int i = 0; i < H; i++)
                {
                    map[i] = Console.ReadLine();
                }

                int x = 0, y = 0;

                while (true)
                {
                    isVisit[y, x] = true;

                    switch (map[y][x])
                    {
                        case '>':
                            x++;
                            break;
                        case '<':
                            x--;
                            break;
                        case '^':
                            y--;
                            break;
                        case 'v':
                            y++;
                            break;
                    }

                    if (map[y][x] == '.')
                    {
                        sb.AppendLine(x + " " + y);
                        break;
                    }

                    if (isVisit[y, x])
                    {
                        sb.AppendLine("LOOP");
                        break;
                    }
                }
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	vector<int> cnt(n,-1);
	bool flag=true;
	rep(i,m){
		int s,c;
		cin>>s>>c;
		s--;
		if(cnt[s]==-1){
			cnt[s]=c;
		}else{
			if(cnt[s]!=c){
				flag=false;
			}
		}
	}
	if(!flag){
		cout<<-1<<endl;
		return 0;
	}
	rep(i,1000){
		string now=to_string(i);
		if(now.size()!=n) continue;
		bool f=true;
		rep(j,now.size()){
			if(cnt[j]==-1) continue;
			if(cnt[j]!=int(now[j]-'0')){
				f=false;
			}
		}
		if(f){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
}

Measured memory_bytes: 256
N, A, B, C = gets.split.map(&:to_i)
Q = N.times.map{ gets.chomp }

ABC = {'A' => A, 'B' => B, 'C' => C}

result = true
choose = []

until Q.empty?
  q = Q.shift
  h = Q.first
  
  l = q[0]
  r = q[1]
  
  if ABC[l].zero? && ABC[r].zero?
    result = false
    break
  elsif ABC[l].zero?
    ABC[l] += 1
    ABC[r] -= 1
    choose << l
  elsif ABC[r].zero?
    ABC[r] += 1
    ABC[l] -= 1
    choose << r
  elsif ABC[l] == 1 && ABC[r] == 1
    if h.nil? || h.include?(l)
      ABC[l] += 1
      ABC[r] -= 1
      choose << l
    else
      ABC[r] += 1
      ABC[l] -= 1
      choose << r
    end
  else
    if ABC[l] <= ABC[r]
      ABC[l] += 1
      ABC[r] -= 1
      choose << l
    else
      ABC[r] += 1
      ABC[l] -= 1
      choose << r
    end
  end
end
if result
  puts 'Yes'
  puts choose
else
  puts 'No'
end

Measured memory_bytes: 25268
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cerr<<(#v)<<":";for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;
#define printVS(vs) cerr<<(#vs)<<":"<<endl;for(auto(s):(vs)){cerr<<(s)<< endl;}
#define printVV(vv) cerr<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;}
#define printP(p) cerr<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cerr<<(#vp)<<":"<<endl;for(auto(p):(vp)){cerr<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cerr << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cerr << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1ll << 60;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

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

    int n, m, t;
    cin >> n >> m >> t;
    vi a(n);
    rep(i, n) cin >> a[i];

    int ans = 0;
    ans += max(0ll, a[0] - m);
    ans += max(0ll, t - (a.back() + m));
    rep(i, n - 1) {
        ans += max(0ll, a[i + 1] - a[i] - 2 * m);
    }

    cout << ans << endl;

}

Measured memory_bytes: 3152
N, K = list(map(int, input().split()))
S = list(input())
K -= 1

if S[K] == 'A': S[K] = 'a'
elif S[K] == 'B': S[K] = 'b'
elif S[K] == 'C': S[K] = 'c'

print(''.join(S))

Measured memory_bytes: 3060
#include <stdio.h>
int main(int argc, char *argv[]){
    int H,W;
    while(1){
    scanf("%d %d",&H,&W);
        if(H==0&&W==0){
            break;
        }
    for(int j=0;j<H;j++){
        for(int i=0;i<W;i++){
            printf("#");
        }
        printf("\n");
    }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2040
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e9;

//Non-decreasing

//入力
ll n;
vector<ll>a;

int main(){
    cin >> n;
    a.resize(n);
    rep(i,n)cin>>a[i];
    ll M = 0;
    ll now = 0;
    rep(i,n){
        if(chmax(M,abs(a[i]))){
            now = i;
        }
    }
    cout << 2*n-2 << endl;
    rep(i,n){
        if(i==now)continue;
        cout << now+1 << ' ' << i+1 << endl;
    }
    if(a[now]>=0){
        rep(i,n-1){
            cout << i+1 << ' ' << i+2 << endl;
        }
    }
    else{
        rep(i,n-1){
            cout << n-i << ' ' << n-i-1 << endl;
        }
    }
    

    return 0;
}


Measured memory_bytes: 3632
hoge=input()
if(hoge=="hi"):
  print("Yes")
elif(hoge=="hihi"):
  print("Yes")
elif(hoge=="hihihi"):
  print("Yes")
elif(hoge=="hihihihi"):
  print("Yes")
elif(hoge=="hihihihihi"):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  string A;
  cin >> A;
  ll N = A.size();
  vector<ll> cnt(26);
  for(char c: A) cnt[int(c-'a')]++;
  ll sub = 0;
  rep(i, 26) sub += cnt[i]*(cnt[i]-1)/2;
  cout << N*(N-1)/2-sub+1 << endl;
  return 0;
}


Measured memory_bytes: 640