akhauriyash/Code-Regression huggingface dataset:
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define fi first
#define se second

const int64 MOD = 1e9 + 7;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n; cin >> n;
  int A = 0, C = 1, G = 2, T = 3;
  int64 dp[110][4][4][4] = {};

  rep(i, 4){
    rep(j, 4){
      rep(k, 4){
        if (i == A && j == G && k == C) continue;  //  AGC
        if (i == G && j == A && k == C) continue;  //  GAC
        if (i == A && j == C && k == G) continue;  //  ACG
        dp[3][i][j][k] = 1;
      }
    }
  }

  for (int i = 3; i <= 100; ++i){
    rep(j, 4){
      rep(k, 4){
        rep(l, 4){
          rep(m, 4){
            if (k == A && l == G && m == C) continue;  //  AGC
            if (k == G && l == A && m == C) continue;  //  GAC
            if (k == A && l == C && m == G) continue;  //  ACG
            if (j == A && l == G && m == C) continue;  //  A?GC
            if (j == A && k == G && m == C) continue;  //  AG?C
            dp[i + 1][k][l][m] += dp[i][j][k][l];
            dp[i + 1][k][l][m] %= MOD;
          }
        }
      }
    }
  }

  int64 ans = 0;
  rep(i, 4){
    rep(j, 4){
      rep(k, 4){
        ans += dp[n][i][j][k];
      }
    }
  }
  print(ans % MOD);

  return 0;
}

Measured memory_bytes: 256
A=(input())
B=(input())
C=(input())
lis=['','','']
lis[0]=A
lis[1]=B
lis[2]=C

turn = 0

while len(lis[turn])>0:
    if lis[turn][0:1]=='a':
        lis[turn]=lis[turn][1:]
        turn =0
    elif lis[turn][0:1]=='b':
        lis[turn]=lis[turn][1:]
        turn=1
    elif  lis[turn][0:1]=='c':
        lis[turn]=lis[turn][1:]
        turn=2
        
if turn==0:
    print('A')
elif turn ==1:
    print('B')
elif turn ==2:
    print('C')

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

int digitsSum(int num){
    int sum = 0;
    while(num > 0){
        sum += num % 10;
        num /= 10;
    }
    return sum;
}

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

    int ans = 1000;

    for(int i = 1; i < n; i++){
        int sumA = digitsSum(i);
        int sumB = digitsSum(n - i);
        ans = min(ans, sumA + sumB);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int N; cin >> N;
    string S; cin >> S;
    string ans = S;
	int cnt = 0;
	rep(i, N) {
		if(S[i] == '(') cnt ++;
		if(S[i] == ')') cnt --;
		if(cnt == -1) {
			ans = '(' + ans;
			cnt = 0;
			continue;
		}
	}
	while(cnt > 0) {
		ans += ')';
		cnt --;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    ll i,j;
    ll n;
    cin>>n;

    ll x;

    ll b[n+1];

    for(i=1;i<=n;i++){
        cin>>x;
        b[x]=i;
    }

    set<ll> s,t;
    s.insert(0);
    s.insert(n+1);
    t.insert(0);
    s.insert(-n-1);


    ll l[n+1];
    ll r[n+1];

    for(i=1;i<=n;i++){
        l[i]=b[i]+ *t.upper_bound(-b[i]);
        r[i]=*s.upper_bound(b[i])-b[i];
        s.insert(b[i]);
        t.insert(-b[i]);
    }
    ll ans=0;
    for(i=1;i<=n;i++){
        ans+=i*l[i]*r[i];
    }

    cout<<ans<<endl;



}


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

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  ll s = 0;
  rep(i,n) s ^= a[i];
  ll ans = s;
  rep(i,n) a[i] &= ~s;

  int r = 0;
  vector<int> top(n);
  for (int i = 60; i >= 0; --i) {
    int j = r;
    for (; j < n; ++j) {
      if (a[j]>>i&1) {
        swap(a[r],a[j]);
        break;
      }
    }
    if (j == n) continue;
    top[r] = i;
    rep(k,n) {
      if (r == k) continue;
      if (a[k]>>i&1) a[k] ^= a[r];
    }
    ++r;
  }

  ll x = 0;
  for (int i = 60; i >= 0; --i) {
    ll nx = x|(1ll<<i);
    {
      ll b = nx;
      rep(j,r) {
        if (b>>top[j]&1) b ^= a[j];
      }
      if ((b&nx) == 0) {
        x = nx;
      }
    }
  }
  ans += x*2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
int main()
{
	int H,W;
	cin >> H >> W;
	char s[50][50];
	for(int i=0; i<H; i++)
	{
		for(int j=0; j<W; j++)
		{
			cin >> s[i][j];
		} 
	}	
	bool flag = true;
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			bool k = false;
			if(s[i][j] == '.') 
			{
				continue;
			}
			if(i>0)
			{
				if(s[i-1][j] == '#') k =true;
			}
			if(i+1<H)
			{
				if(s[i+1][j] == '#') k=true;
			}
			if(j>0)
			{
				if(s[i][j-1] == '#') k=true;
			}
			if(j+1<W)
			{
				if(s[i][j+1] == '#') k=true;
			}
			if(!k) 
			{
				flag = false;
			}
			if(!flag)
			{
				cout << "No";
				return 0;
			}
		}
	}
	cout << "Yes";
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string.h>

using namespace std;

int line[1024][128];

int main()
{
	int n, m, a;
	
	while (1){
		cin >> n >> m >> a;
		
		if (!n && !m && !a){
			break;
		}
		
		memset(line, 0, sizeof(line));
		
		for (int i = 0; i < m; i++){
			int h, p, q;
			cin >> h >> p >> q;
			
			line[h][p] = q;
			line[h][q] = p;
		}
		
		for (int i = 1000; i > 0; i--){
			if (line[i][a] != 0){
				a = line[i][a];
			}
		}
		
		printf("%d\n", a);
	}
	
	return 0;
}

Measured memory_bytes: 1664
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include<unordered_set>
#include<complex>
#include <cassert>

using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 20;

int n, m, x;
int A[MAX][MAX];
int C[MAX];
int S[MAX];

int getPrice(int mask) {
    int ans = 0;
    FOR(i, 0, n) {
        if (mask & (1 << i)) {
            ans += C[i];
        }
    }

    return ans;
}

bool canAchive(int mask) {
    FILL(S, 0);
    FOR(i, 0, n) {
        if (mask & (1 << i)) {
            FOR(j, 0, m) {
                S[j] += A[i][j];
            }
        }
    }

    FOR(i, 0, m) {
        if (S[i] < x) return false;
    }

    return true;
}

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //ios::sync_with_stdio(false); cin.tie(0);
    cin >> n >> m >> x;
    FOR(i, 0, n)
    {
        cin >> C[i];
        FOR(j, 0, m) cin >> A[i][j];
    }

    int ans = INF;
    FOR(mask, 0, 1 << n) {
        if (canAchive(mask)) {
            ans = min(ans, getPrice(mask));
        }
    }

    if (ans == INF) {
        cout << -1 << endl;
        return 0;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<limits.h>
#include<float.h>

#define N 100001

typedef struct _Stack {
	bool isZero[N];
	int num;
} Stack;

void push(Stack *s, bool isZero){
	s->isZero[s->num++] = isZero;
}

bool pop(Stack *s){
	return s->isZero[--s->num];
}

bool top(Stack *s){
	return s->isZero[s->num-1];
}

bool isEmpty(Stack *s){
	return s->num == 0;
}

int main(){
	char str[N], *c;
	int ans = 0;
	Stack s;
	s.num = 0;
	scanf("%s\n", str);
	c = str;
	while(*c){
		bool isZero;
		if(*c == '0') isZero = true;
		else isZero = false;
		if(isEmpty(&s) || top(&s) == isZero) push(&s, isZero);
		else {
			pop(&s);
			ans +=2;
		}
		c++;
	}
	printf("%d", ans);
	return 0;
}




Measured memory_bytes: 384
import sys
fin = sys.stdin.readline


MAX_INT = (1 << 63) - 1
N, W = [int(elem) for elem in fin().split()]
weight_value_pairs = tuple(tuple(int(elem) for elem in fin().split()) for _ in range(N))
max_value = max(v for _, v in weight_value_pairs)
max_total_value = N * max_value

dp = [MAX_INT] * (max_total_value + 1)
dp[0] = 0
for i in range(N):
    w, v = weight_value_pairs[i]
    for j in reversed(range(max_total_value + 1)):
        dp[j] = min(dp[j], dp[j - v] + w)

max_val = 0
for val, total_weight in enumerate(dp):
    if total_weight <= W:
        max_val = val
print(max_val)


Measured memory_bytes: 79836
import java.io._
import scala.io.StdIn.{readInt, readLine}

object Main {
  val out:BufferedWriter =
    new BufferedWriter(new OutputStreamWriter(new FileOutputStream(java.io.FileDescriptor.out), "ASCII"), 512)
  var count = 0
  class Node(var key:Int, var left:Node = null, var right:Node = null) { }

  def insert(tree:Node, key:Node) = {
    val keyNode = key
    def getNodeToInsert(node:Node):Node =
      if(node.key > keyNode.key) {
        if(node.left == null) node
        else getNodeToInsert(node.left)
      } else {
        if(node.right == null) node
        else getNodeToInsert(node.right)
      }

    val target = getNodeToInsert(tree)

    if(keyNode.key < target.key) target.left = keyNode
    else target.right = keyNode
  }

  def inOrder(tree:Node):Unit =
    if(tree == null) return
    else {
      inOrder(tree.left)
      out.write(" ")
      out.write(tree.key.toString)
      if(count<100) count += 1
      else {
        out.flush
        count = 0
      }
      inOrder(tree.right)
    }

  def preOrder(tree:Node):Unit =
    if(tree == null) return
    else {
      out.write(" ")
      out.write(tree.key.toString)
      if(count<100) count += 1
      else {
        out.flush
        count = 0
      }
      preOrder(tree.left)
      preOrder(tree.right)
    }

  def main(args:Array[String]) = {
    val n = readInt
    val tree = new Node(-1)

    for(i<-0 until n) {
      val s = readLine.split(" ")
      s(0) match {
        case "insert" =>
          if(tree.key == -1) tree.key = s(1).toInt
          else insert(tree, new Node(s(1).toInt))
        case _ => {
          inOrder(tree)
          out.write("\n")
          out.flush()
          preOrder(tree)
          out.write("\n")
          out.flush()
        }
      }
    }
  }
}

Measured memory_bytes: 307280
#include<stdio.h>
int main()
{
  int X,Y,Z,temp1,temp2;
  scanf("%d%d%d",&X,&Y,&Z);
  temp1=X;
  X=Y;
  Y=temp1;
  temp2=X;
  X=Z;
  Z=temp2;
  printf("%d %d %d",X,Y,Z);
  return (0);
}


Measured memory_bytes: 128
N = input()
N_row = len(N)
while True:
  if N_row == 1:
    print(int(N))
    break
  else:
    N = list(N)
    a = int(N[0])
    b = int(N[-1])
    for i in range(1, N_row):
      if not int(N[i]) == 9:
        sum = (a-1) + 9*(N_row-1) 
        print(sum)
        break
    else:
      sum = a + 9*(N_row-1)
      print(sum)
      break
  break

Measured memory_bytes: 9144
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <tuple>
#include <cmath>
#include <map>

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define F first
#define S second

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

constexpr ll MOD = 1000000007LL;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

template<typename T = ll> class UnionFind {
public:
	UnionFind( T n ) { rep( i, n ) { par.resize( n ); siz.resize( n ); par[i] = i; siz[i] = 1; } }
	T find( T x ) { if ( x == par[x] ) return ( x ); else return( par[x] = find( par[x] ) ); }
	void unite( T x, T y ) { T xx = find( x ); T yy = find( y ); if ( xx == yy ) return;
		if ( siz[xx] <= siz[yy] ) swap( xx, yy ); par[yy] = xx; siz[xx] += siz[yy]; }
private:
	vector<T> par, siz;
};

template<typename T = ll> T power( T a, T b, T m = MOD ) {
	T res = 1;
	while ( b > 0 ) { if ( b & 1 ) res = res * a % m;
		a = a * a % m; b >>= 1; }
	return ( res );
}

/*
constexpr ll MAX = 500010;
ll fact[MAX];
ll inv[MAX];
ll inv_fact[MAX];

template<typename T> void initComb( T n, T m = MOD )
{
	fact[0] = fact[1] = inv_fact[0] = inv_fact[1] = 1;
	inv[1] = 1;
	for ( int i = 2; i < n; i++ ) {
		fact[i] = ( fact[i - 1] * i ) % m;
		inv[i] = m - inv[m % i] * ( m / i ) % m;
		inv_fact[i] = inv_fact[i - 1] * inv[i] % m;
	}
}

template<typename T> T comb( T n, T r, T m = MOD )
{
	if ( n < r ) return ( 0 );
	if ( n < 0 || r < 0 ) return ( 0 );
	return ( fact[n] * ( inv_fact[r] * inv_fact[n - r] % m ) % m );
}
*/

void replace( string &s, string t, string r ) {
	string::size_type p = 0;
	while ( ( p = s.find( t, p ) ) != string::npos ) {
		s.replace( p, t.length(), r );
		p += r.length();
	}
}


int main()
{
	ll N, K;
	cin >> N >> K;

	if ( K != 0 )
	{
		ll total = 0;
		reps( i, N )
		{
			total += ( N / i ) * max( 0LL, (ll)i - K );
			total += max( 0LL, N % i - K + 1 );
		}

		cout << total << endl;
	}
	else
	{
		cout << ( N * N ) << endl;
	}

	return ( 0 );
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main() {
  string s;
  cin >> s;
  int hug = 0;
  for (int i = 0; i < s.size()/2; i++) {
    if(s[i] != s[s.size()-1-i]) {
      hug++;
    }
  }
  cout << hug;
  return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N, M; scanf("%d %d", &N, &M);
  vector<vector<bool>> adj(N + 5, vector<bool>(N + 5));
  int a, b;
  for (int i = 0; i < M; ++i) {
    scanf("%d %d", &a, &b);
    adj[a][b] = adj[b][a] = true;
  }

  vector<int> V;
  for (int i = 1; i <= N; ++i) {
    V.push_back(i);
  }

  int ans = 0;
  sort(V.begin(), V.end());
  do {
    bool ok = true;
    for (int i = 0; i < N - 1; ++i) {
      if (not adj[V[i]][V[i + 1]]) {
        ok = false;
        break;
      }
    }
    if (ok) { ++ans; }
  } while (next_permutation(V.begin() + 1, V.end()));

  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(), v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 1;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int n;
        cin >> n;
        int g = 0;
        int a[n];
        map<int, int> vis;
        for(int &it : a){
            cin >> it;
            vis[it] = 1;
            g = __gcd(g, it);
        }
        if(g > 1){
            cout << "not coprime\n";
        }else{
            int flag = 1;
            vector<int> prime((int)1e6 + 1, 1);
            for(int i = 2; i <= 1e6; i++){
                if(!prime[i]){
                    continue;
                }
                int cnt = 0;
                if(vis[i]){
                    cnt++;
                }
                for(int j = 2 * i; j <= 1e6; j += i){
                    if(vis[j]){
                        cnt++;
                    }
                    prime[j] = 0;
                }
                if(cnt > 1){
                    flag = 0;
                    break;
                }
            }
            if(flag){
                cout << "pairwise coprime\n";
            }else{
                cout << "setwise coprime\n";
            }
        }
    }
}

Measured memory_bytes: 112468
s = input()
m = 10**9 + 1
# i,i+1のどちらかから選んで文字列にする
for alpha in set(s):
    temp = alpha + s + alpha
    M = 0
    now = 0
    for i, key in enumerate(temp):
        if key == alpha:
            if M < i - now - 1:
                M = i - now - 1
            now = i
    if m > M:
        m = M

print(m)

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

int main() {
    string s,t,u;
    int a,b;
    cin >> s >> t >> a >> b >> u;
    if(s == u) a--;
    else b--;
    cout << a << " " << b << endl;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 300001

int gcd(int a, int b) {
    if(a < b) swap(a, b);
    if (b==0) return a;
    return gcd(b, a%b);
}

int A[MAXN], B[MAXN];
int n, q;
int x,y;
int tmp;
int main() {
    cin >> n;
    for(int i=0; i<n; i++) {
        cin >> A[i];
        B[i] = A[i];
    }

    sort(B, B+n);

    cin >> q;

    int cnt =0;

    for(int i=0; i<n; i++) {
        if (A[i] == B[i]) cnt ++;
    }

    int ans;
    for(ans=0; ans<q; ans++) {
        cin >> x >> y;
        x--;
        y--;
        if (cnt == n) break;
        if (A[x] == B[x]) cnt--;
        if (A[y] == B[y]) cnt--;
        
        tmp = A[x];
        A[x] = A[y];
        A[y] = tmp;

        if (A[x] == B[x]) cnt++;
        if (A[y] == B[y]) cnt++;
    } 
    if (cnt != n) ans=-1;
    cout << ans << endl;

}




Measured memory_bytes: 5512
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        
        if(a > b){
            System.out.println("a > b");
        }else if(a == b){
            System.out.println("a == b");
        }else{
            System.out.println("a < b");
        }
        
    }
}
 


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

void swap(int *x, int *y){
	int tmp;
	tmp = *x;
	*x = *y;
	*y = tmp;
}


int main(){
	int x, y;
	while(cin >> x >> y){
		if(x== 0 && y == 0) break;
		if(x > y) swap(&x, &y);
		cout << x << " " << y << endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
bool isPalindrome(const string &s) {
  int n = (int)s.size();
  for(int i = 0; i < n/2; ++i) {
    if(s[i] != s[n-i-1])return false;
  }
  return true;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int div = (int)s.size()/2;
  string lf = s.substr(0, div);
  string rg = s.substr(div+1, string::npos);
  if(lf != rg || !isPalindrome(lf) || !isPalindrome(rg)){
    puts("No");
  } else {
    puts("Yes");
  }
  return 0;
}

Measured memory_bytes: 256
H = int(input())
A = list(map(int, input().split()))

class HeapTree:
    def __init__(self,A):
        self.heap = [-1] + A
        self.l = len(self.heap)-1
        self.buildMaxHeap()


    def maxHeapify(self,i):
        left_child = self.left_child(i)
        right_child = self.right_child(i)
        larger = i
        if left_child and self.heap[left_child] > self.heap[i]:
            larger = left_child
        if right_child and self.heap[right_child] > self.heap[larger]:
            larger = right_child
        
        if larger != i:
            tmp = self.heap[i]
            self.heap[i] = self.heap[larger]
            self.heap[larger] = tmp
            self.maxHeapify(larger)

    def parent(self,i):
        return i//2

    def left_child(self,i):
        if 2*i <= self.l:
            return 2*i
        else:
            return False
            
    def right_child(self,i):
        if 2*i+1 <= self.l:
            return 2*i+1
        else:
            return False
    
    def buildMaxHeap(self):
        max_ind_parent = self.parent(self.l)
        for i in range(max_ind_parent,0,-1):
            self.maxHeapify(i)

heap_tree = HeapTree(A)
print(" ",end="")
print(*heap_tree.heap[1:])




Measured memory_bytes: 63720
#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> a;
int main() {
    cin >> n;
    a = vector<int>(n, 0);
    for(int i = 0; i < n; ++i) {
        cin >> a.at(i);
    }

    int tar = 1;
    int cnt = 0;
    for(int i = 0; i < n; ++i) {
        if(a.at(i) != tar) {
            cnt++;
        }else {
            tar++;
        }
    }

    if(cnt == n) {
        cout << -1 << endl;
    }else {
        cout << cnt << endl;
    }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int sum = 0;
	for(int i = 0; i < 3; i++){
		char c = cin.get();
		sum += (c == '1');
	}
	cout << sum << "\n";
	return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
s = ["."*(w+2)] + ["."+input()+"." for i in range(h)] + ["."*(w+2)] 
ans = [[0]*(w+2) for i in range(h+2)]
for i in range(1, h+1):
    for j in range(1, w+1):
        if s[i][j] == "#":
            for x in [-1, 0, 1]:
                for y in [-1, 0, 1]:
                    if ans[i+x][j+y] != "#":
                        ans[i+x][j+y] += 1 
            ans[i][j] = s[i][j]
for i in range(1, h+1):
    print(*(ans[i][1:w+1]), sep="")

Measured memory_bytes: 44656
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> X(N), L(N);
    vector<pair<ll, ll>> v;
    REP(i,N){
        cin >> X[i] >> L[i];
        v.emplace_back(X[i]+L[i], X[i]-L[i]);
    }
    sort(v.begin(), v.end());
    ll cur = -LINF;
    int ans = 0;
    for(auto x : v){
        if(cur <= x.second){
            cur = x.first;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4084
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define ALL(n) begin(n),end(n)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
template<class T> inline T CHMAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T CHMIN(T & a, const T b) { return a = (a > b) ? b : a; }

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
const long long MOD = 1000000007;

int main(void){
    ll x;
    ll n;
    vector<ll> nums;
    cin >>x >> n;
    REP(i,n){
        ll tmp;
        cin >> tmp;
        nums.push_back(tmp);
    }
    sort(ALL(nums));

    ll distance =0;
    if(!( find(ALL(nums), x)!= nums.end()) ){
        cout << x << endl;
    }else{
        while(1){
            ll ansA = x+distance;
            ll ansB = x-distance;
            bool existA = (find(ALL(nums), ansA)!= nums.end());
            bool existB = (find(ALL(nums), ansB)!= nums.end());
            if(! existB ){
                cout << ansB << endl;
                return 0;
            }else if(! existA){
                cout << ansA << endl;
                return 0;
            }
            distance ++;
        }
    }
    return 0;
}

Measured memory_bytes: 3192
#include <iostream>
using namespace std;
int main(){
int N;
cin>>N;
int A[N];
for(int i=0;i<N;i++){
cin>>A[i];
}
int j=0;
int m=100;
for(int k=0; k<N; k++){
j=0;
	for(int l=0; A[k]%2==0; l++){
	j++;
	A[k]=A[k]/2;
	}
if (m>j){
m=j;}
}
cout<<m<<endl;
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <limits>

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

int main(){
    ll n, t;
    cin >> n >> t;
    ll maxv = 0;
    ll ans = 0;
    ll mina = numeric_limits<ll>::max();
    REP(i, n){
        ll a;
        cin >> a;

        if(mina < a){
            if(a - mina > maxv){
                maxv = a - mina;
                ans = 1;
            }else if(a - mina == maxv){
                ans++;
            }
        }

        mina = min(mina, a);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
string s1, s2, s3;
char a, b, c;

int main(){
	cin >> s1 >> s2 >> s3;
	a=s1[0]-'a'+'A';
	b=s2[0]-'a'+'A';
	c=s3[0]-'a'+'A';
	cout << a << b << c << endl;
	return 0;
}


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

int main() {
  int n,m;
  cin>>n>>m;
  vector<pair<long,long>>a;
 
  rep(i,n){
    int A,B;
    cin >> A>>B;
    a.push_back(pair<int,int>(A,B));
  }
  sort(a.begin(), a.end());
  
  int ans=0;
  int k=0;
  
  priority_queue<int>p;
  rep2(i,1,m+1){
    rep2(j,k,n){
      if(a[j].first==i){
        p.push(a[j].second);
      }
      else{
        k=j;
        break;
      }
    }
    if(!p.empty()){
      ans+=p.top();
      p.pop();
    }
  }
    
  
  cout<<ans<<endl; 
}

Measured memory_bytes: 2672
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
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;
const ll MOD = 1e9 + 7;

int f(int x, int y, int z){
    return x*x + y*y + z*z + x*y + x*z + y*z;
}

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

    vector<int> v(n+1);
    for(int i=1; i<=n; i++){
        for(int j=1; j<=n; j++){
            for(int k=1; k<=n; k++){
                if(f(i, j, k) > n) break;
                v[f(i, j, k)]++;
            }
        }
    }

    for(int i=1; i<=n; i++) cout << v[i] << endl;
}

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

int main() {
    
    int plus[999]={0};
    int ans=-1, n,x; 
    cin>>x>>n;
   if(n==0){
        cout<<x;
    	return 0;
   }
   vector<int>v;
   
   for(int i=0; i<n; i++){
       int p;
      cin>>p;
    //   v.push_ back(p);
        plus[p]=1;
       
   }
   int j=0;
    while(1){
        if(j>x)
            {
                cout<<"-1";
                return 0;
            }
        if(plus[x-j]==0){
            cout<<x-j;
            return 0;
        }
        else if(plus[x+j]==0){
             cout<<x+j;
            return 0;
        }
        else j++;
            
        
    }  
  
   
   return 0;
   
}


Measured memory_bytes: 3600
s = io.read()
a, b, c = s:match("(%w+) (%w+) (%w+)")
a = string.char(a:sub(1, 1):byte() - 32)
b = string.char(b:sub(1, 1):byte() - 32)
c = string.char(c:sub(1, 1):byte() - 32)
print(a .. b .. c)

Measured memory_bytes: 508
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,m,x,y;
    cin >> n >> m >> x >> y;
    vector<int> a(n);
    vector<int> b(m);
    int ma=-101,mi=101;
    rep(i,n) {
        cin >> a[i];
        ma = max(ma,a[i]);
    }
    rep(i,m) {
        cin >> b[i];
        mi = min(mi,b[i]);
    }

    // cout << ma << " " << mi << endl;
    for(int i = ma+1;i <= mi;i++){
        if((i>x)&&(i<=y)){
            cout << "No War" << endl;
            return 0; 
        }
    }
    cout << "War" << endl;
    
    return 0;
}

Measured memory_bytes: 3624
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
#include <float.h>
#include <math.h>
#include <sstream>
#include <iterator>
using namespace std;
// repマクロの定義
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
// allマクロの定義
#define all(v) v.begin(), v.end()
// 大きい順
#define rall(v) v.rbegin(), v.rend()
#define vi vector<int>
#define vl vector<ll>
const  long long INF = 1LL << 60;
typedef  long long ll;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}



int ctoi(char c) {
 	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}

bool is_prime(const unsigned n){
    switch(n){
        case 0: // fall-through
        case 1: return false;
        case 2: // fall-through
        case 3: return true;
    } // n > 3 が保証された

    if(n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である

    // 6の倍数前後の数を使って試し割りをする
    for(unsigned i = 5; i * i <= n; i += 6) {
        if(n % i     == 0) return false; // (6の倍数)-1
        if(n % (i+2) == 0) return false; // (6の倍数)+1
    }

    return true;
}

map<ll,ll> mp;

ll primeFactorization(ll a){ //素因数分解を出力するプログラム
    ll i,sq;
    if(a%2==0){ //偶数の場合
        if(!mp.count(2)){
            mp[2] = 1;
        }
        else{
            mp[2] +=1;
        }
        return primeFactorization(a/2); //2で割った値で再帰
    }
    sq = sqrt(a);
    for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
        if(a%i==0){
            if(!mp.count(i)){
                mp[i] = 1;
            }
            else{
                mp[i] += 1;
            }
            return primeFactorization(a/i); //割れた値で再帰
        }
    }
    //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
    if(a!=1){ //aが1でないなら、a自身は素数
        if(!mp.count(a))
        mp[a] = 1;
        else{
            mp[a] += 1;
        }
    }
    return 0;
}


ll kaizyou(ll n){
    if(n == 1){
        return 1;
    }
    else{
        return (n * kaizyou(n-1)) % 1000000007;
    }
}



int main(){
int y;
rep(i,5) {
    int x;
    cin >> x;
if(x == 0) y = i+1;
}
cout << y << endl;
}

Measured memory_bytes: 3620
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;


int main(){
    int H,W;
    char c[52][52]; 
    cin>>H>>W;
    for(int i=0;i<H;i++){
        cin>>c[i];
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(c[i][j]!='#'){
                int a=0;
                for(int k=-1;k<=1;k++){
                    for(int l=-1;l<=1;l++){
                        int h=i+k;
                        int w=j+l;
                        if(0<=h && h<H && 0<=w && w <W && c[h][w]=='#'){
                            a++;
                           // cout<<h<<w<<endl;
                        }
                    }
                }
                c[i][j]=a+'0';
            }
            cout<<c[i][j];
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <inttypes.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
    char S[(int)2e5 + 1], T[(int)2e5 + 1];
    intmax_t ans = 0;

    gets(S);
    gets(T);

    for (size_t i = 0; i < strlen(S); i++) {
        if (S[i] != T[i])
            ans++;
    }

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

    return 0;
}


Measured memory_bytes: 2448
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i!=n;++i)
#define Rep(i,a,b) for(int i=0;i<b;++i)
#define REP(i,a,b) for(int i=0;i<=b;++i)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout <<(f?"Yes":"No")<<endl//fが真の場合Yesを出力、偽の場合Noを出力
#define yes(f) cout <<(f?"yes":"no")<<endl
#define YES(f) cout <<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())

using namespace std;

const int mod=1e9+7;

signed main(){
    int n,d;
    cin >> n >> d;
    vvi point(n,vi(d));
    rep(i,n)
    {
        rep(j,d)
        {
            cin >> point[i][j];
        }

    }

    int ans=0;
    rep(i,n)
    {
        for(int j=i+1;j<n;++j)
        {
            int num=0;
            rep(k,d)
            {
                int dif = abs(point[i][k]-point[j][k]);
                num+=dif*dif;
            }
            for(int k=0;k<=num;++k)
            {
                if(k*k==num)ans++;
            }
        }
    }

    cout << ans << endl;
}

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

int main()
{
    int n, a, b;
    cin >> n ;
    if(n==1){
        cout << "Hello World" << endl;
    }
    else{
        cin >> a >> b;
        cout << a+b << endl;
    }
    return 0;
}

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

vector<ll> dp(101010,0);

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

    dp[0] = 1;
    for(int i=3;i<=s;i++){
        dp[i] = dp[i-1] + dp[i-3];
        dp[i] %= MOD;
    }
    dp[s] %= MOD;
    cout << dp[s] << endl;
}

Measured memory_bytes: 3892
#include <iostream>
#include <functional>
#include <algorithm>
#include <climits>
#include <string>
#include <vector>
#include <map>
#include <cmath>

using namespace std;

namespace _{struct _{_(){ // initialize
  cin.tie(0); ios::sync_with_stdio(false);
}}_;}
template <typename T, size_t size>
inline size_t len(const T (&)[size]) { return size; }
#define println(s) cout << s << '\n';
#define str to_string
#define rep(i, n) for (int i=0; i<int(n); i++)
#define all(c) (c).begin(), (c).end()


int main() {
  while (true) {
    int n; cin >> n;
    if (n == 0) break;

    int A = 0;
    int B = 0;
    rep(i, n) {
      int a, b;
      cin >> a >> b;
      if (a == b) {
        A += a; B += b;
      } else if (a > b)
        A += (a+b);
      else
        B += (a+b);
    }

    cout << A << " " << B << endl;
  }
  return 0;
}

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

void print(char x[], ll n)
{
	for(int i = 0; i < n; i++)
		cout << x[i] << " ";
	cout << endl;
}
char x[1005][1005];
int h, w;
ll dp[1005][1005];
ll paths(int r, int c)
{
	if(x[r][c]=='#')
		return 0;
	if(r == h-1 && c == w-1)
		return 1;
	if(r < h && c < w && dp[r][c] != -1)
		return dp[r][c];
	if(r < h && c < w)
	{
		dp[r][c] = (paths(r+1, c)+paths(r, c+1))%1000000007;
		return dp[r][c];
	}
	return 0;
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> h >> w;
	string s;
	memset(dp, -1, sizeof dp);
	for(int i = 0; i < h ; i++)
	{
		cin >> s;
		for(int j = 0; j < w; j++)
			x[i][j] = s[j];
	}
	cout << paths(0, 0) << endl;	

	return 0;
}

Measured memory_bytes: 9216
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    string S; cin >> S;
    int N=SZ(S);
    bool can=true;
    rep(i,N/2){
        if(S[i]!=S[N-i-1]) can=false;
    }
    rep(i,N/2/2){
        if(S[i]!=S[N/2-i-1]) can=false;
    }
    rep(i,N/2/2){
        if(S[(N+3)/2-1+i]!=S[N-i-1]) can=false;
    }
    if(can) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
/**
 * Combinatorial - Coin Changing Problem
 */

#include <iostream>

using namespace std;

const int INF = 1 << 29;

int main() {

    int n, m;
    cin >> n >> m;

    int dp[n + 1];
    fill(dp, dp + n + 1, INF);
    dp[0] = 0;

    for (int i = 0; i < m; i++) {
        int c;
        cin >> c;
        for (int j = c; j <= n; j++) {
            dp[j] = min(dp[j], dp[j - c] + 1);
        }
    }

    cout << dp[n] << endl;
}

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

#define FOR(i,a,b)    for (int i=(a)  ;i<(b) ;i++)
#define RFOR(i,a,b)   for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)      for (int i=0    ;i<(n) ;i++)
#define RREP(i,n)     for (int i=(n)-1;i>=0  ;i--)
#define EACH(i,a,b)   for (int i=(a)  ;i<=(b);i++)
#define REACH(i,a,b)  for (int i=(b)  ;i>=(a);i--)
#define ALL(a)        (a).begin(),  (a).end()
#define RALL(a)       (a).rbegin(), (a).rend()

const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const double EPS = 1e-10;

using ll = long long;
using P = pair<int,int>;
template<class T = int> using V = vector<T>;

template<class T> bool inline chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool inline chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T = int> T inline input() { T x; cin >> x; return (x); }
template<class T> void inline print(T& x) { cout << x << '\n'; }
#define debug(x) cerr << #x << ": " << x << endl;

int dp[100100];

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

  int N;
  cin >> N;
  int h[N];
  REP(i,N) cin >> h[i];

  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);

  FOR(i,2,N) {
    dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
  }

  print(dp[N-1]);

  return 0;
}

Measured memory_bytes: 4400
#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;

int main(){
    int N;
    int tmp;
    ll ans=0;
    cin >> N;
    vector<ll> A, B, C,Bs;
    A.resize(N);
    B.resize(N);
    C.resize(N);
    Bs.resize(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());
    int i, j=0, k=N-1;
    for(j=N-1; j>=0; j--){
        while(B[j]<C[k]){
            if(k<0) break;
            tmp++;
            k--;
        }
        Bs[j]=tmp;
        //cout << Bs[j] << j << endl; 
    }
    for(j=N-2; j>=0; j--){
        Bs[j] = Bs[j]+Bs[j+1];
        //cout << Bs[j] << j << endl;
    }
    //rep(i,N) cout << Bs[i] << endl;
    j=0;
    for(i=0; i<N; i++){
        while(A[i]>=B[j]){
            j++;
            if(j>=N) break;
        }
        if(j>=N) break;
        ans += (ll)Bs[j];
        //cout << ans << endl;
    }
    cout << ans << endl;
    
    return 0;
}

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

int main(){
  int n, v, c;
  cin >> n;
  vector<int>V(n);
  vector<int>C(n);
  
  for (int i = 0; i < n; i++){
    cin >> V.at(i);
  }
  
  for (int i = 0; i < n; i++){
    cin >> C.at(i);
  }
  
  int ans = 0;
  for (int i = 0; i < n; i++){
    if (V.at(i) > C.at(i)){
      ans += (V.at(i) - C.at(i));
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256