akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

struct Edge
{
    int u, v;
    bool rev;

    Edge(int _u, int _v)
    {
        u = _u;
        v = _v;
        rev = false;
    }
    Edge() {};

    void show()
    {
        if (rev) swap(u, v);
        printf("%d %d\n", u + 1, v + 1);
    }
};

const int N = 1e5;

vector<Edge> edges;
vector<int> g[N];
int col[N];
bool used[N];

int getOther(Edge e, int v)
{
    return v ^ e.u ^ e.v;
}

void dfs(int v)
{
    used[v] = true;
    for (int i : g[v])
    {
        int u = getOther(edges[i], v);
        if (!used[u])
        {
            dfs(u);
            if (col[u])
            {
                col[u] ^= 1;
                col[v] ^= 1;
                edges[i].rev = true;
            }
        }
    }
}

int main()
{
    //freopen("input.txt", "r", stdin);


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

    for (int v = 0; v < n; ++v)
    {
        col[v] = 0;
        used[v] = false;
    }
    for (int i = 0; i < m; ++i)
    {
        static int u, v;
        scanf("%d%d", &u, &v);
        --u; --v;
        edges.push_back(Edge(u, v));
        col[u] ^= 1;
        g[u].push_back(i);
        g[v].push_back(i);
    }

    dfs(0);

    if (col[0])
        printf("-1");
    else
        for (Edge& e : edges)
            e.show();


}


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

#define A first
#define B second

ll n;
pii s[5005];
ll dp[5005][5005];
ll inf = (1LL << 60);

// in the first m participants, if k people go, min value of h

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> s[i].A >> s[i].B;
		s[i].A += s[i].B;
	}

	for (int i = 0; i < n; ++i)
		for (int j = 0; j <= 5000; ++j)
			dp[i][j] = inf;

	sort(s, s+n);

	for (int i = 0; i < n; ++i)
		s[i].A -= s[i].B;
	
	for (int i = 0; i < n; ++i)
		for (int k = 0; k <= i+1; ++k) {
			if (i == 0) {
				dp[0][0] = 0;
				dp[0][1] = s[0].B;
				continue;
			}

			dp[i][k] = dp[i-1][k];
			if (dp[i-1][k-1] <= s[i].A)
				dp[i][k] = min(dp[i][k], dp[i-1][k-1] + s[i].B);
		}

	for (int i = 5000; i >= 0; --i) {
		if (dp[n-1][i] != inf) {
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 195840
s = gets.chomp.split('')
k = gets.to_i
s.each_with_index do |t, i|
  next if t == 'a'
  n = 'z'.ord - t.ord + 1
  if n <= k
    s[i] = 'a'
    k -= n
  end
end
m = (s.last.ord - 'a'.ord + k) % 26
s[s.size - 1] = ('a'.ord + m).chr
puts s.join


Measured memory_bytes: 13820
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
#include<climits>
using namespace std;

int main(void)
{
	vector<int> v(5);
	for (int i = 0; i < (int)v.size(); i++)
		cin >> v[i];

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

	int ans = INT_MAX;
	do {
		int sum = 0;
		for (int i = 0; i < (int)v.size(); i++) {
			sum += v[i];
			if (i<(int)v.size()-1 && sum % 10 != 0) {
				sum /= 10;
				sum++;
				sum *= 10;
			}
		}

		ans = min(ans, sum);
	} while (next_permutation(v.begin(), v.end()));

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		char s[][] = new char[H + 2][W + 2];
		String temp = "";
		for (int i = 0; i < H + 2; i++) {
			if (i != 0 && i != H + 1) {
				temp = sc.next();
			}
			for (int j = 0; j < W + 2; j++) {
				if (i != 0 && i != H + 1 && j != 0 && j != W + 1) {
					s[i][j] = temp.charAt(j-1);
				}
			}
		}
		boolean flag = true;
		for (int i = 1; i < H + 1; i++) {
			for (int j = 1; j < W + 1; j++) {
				if (s[i][j] == '#' && s[i][j - 1] == '.' && s[i][j + 1] == '.' && s[i - 1][j] == '.'
						&& s[i + 1][j] == '.') {
					flag = false;
				}
			}
		}
		if (flag) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
#define MOD 1000000007
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main () {
  int a,b;
  cin >> a >> b;
  string s;
  rep(i,0,a){
    cin >> s;
    cout << s << endl << s << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
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; }
template<class T> void PrintVector(const vector<T> &vec) {for (auto val : vec) cout << val << " "; cout << endl;}
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int n; cin >> n;
    vector<int> h(n);
    rep(i, n) cin >> h[i];

    int ans = 0;
    while(1)
    {
        if (*max_element(ALL(h)) == 0) break;

        int i = 0;
        while(i < n)
        {
            if (h[i] == 0) i++;
            else
            {
                ans++;
                while(i < n && h[i] > 0)
                {
                    h[i]--;
                    i++;
                }
            }

        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int[] a = new int[3];
		for(int i=0; i<3; i++){
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		System.out.println(a[2] - a[0]);
	}
}

Measured memory_bytes: 22868
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n;
    cin >> n;
    string s1, s2;
    string c;
    while(s1.length() < n && c != "end"){
        printf("%s.\n%s.\n", s1.c_str(), s2.c_str());   fflush(stdout);
        cin >> c;
        if (c == "T" || c == "end"){
            s1 += '.';
            s2 += '.';
            continue;
        }        
        printf("%s.\n%s#\n", s1.c_str(), s2.c_str());   fflush(stdout);
        cin >> c;
        if (c == "T" || c == "end"){
            s1 += '.';
            s2 += '#';
            continue;
        }        
        printf("%s#\n%s.\n", s1.c_str(), s2.c_str());   fflush(stdout);
        cin >> c;
        if (c == "T" || c == "end"){
            s1 += '#';
            s2 += '.';
            continue;
        }
        printf("%s#\n%s#\n", s1.c_str(), s2.c_str());   fflush(stdout);
        cin >> c;
        if (c == "T" || c == "end"){
            s1 += '#';
            s2 += '#';
            continue;
        }
        break;
    }
    while(s1.length() < n && c != "end"){
        printf(".%s\n.%s\n", s1.c_str(), s2.c_str());   fflush(stdout);
        cin >> c;
        if (c == "T" || c == "end"){
            s1 = '.' + s1;
            s2 = '.' + s2;
            continue;
        }        
        printf(".%s\n#%s\n", s1.c_str(), s2.c_str());   fflush(stdout);
        cin >> c;
        if (c == "T" || c == "end"){
            s1 = '.' + s1;
            s2 = '#' + s2;
            continue;
        }        
        printf("#%s\n.%s\n", s1.c_str(), s2.c_str());   fflush(stdout);
        cin >> c;
        if (c == "T" || c == "end"){
            s1 = '#' + s1;
            s2 = '.' + s2;
            continue;
        }
        printf("#%s\n#%s\n", s1.c_str(), s2.c_str());   fflush(stdout);
        cin >> c;
        if (c == "T" || c == "end"){
            s1 = '#' + s1;
            s2 = '#' + s2;
            continue;
        }
        break;
    }

    return 0;
}


Measured memory_bytes: 596
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

#define MAX_N (200000)
#define NUM_ELEM (1 << 21)
#define SIZE_BUF (2 * NUM_ELEM - 1)
#define INF (1000000000)

using namespace std;

long revs[MAX_N];

long buf[SIZE_BUF];

void st_init(const long *as, long N) {
  // fill leaves
  for (int i = 0; i < N; i++) {
    buf[NUM_ELEM - 1 + i] = as[i];
  }
  for (int i = N; i < NUM_ELEM; i++) {
    buf[NUM_ELEM - 1 + i] = INF;
  }

  // calculate inner nodes
  for (int i = NUM_ELEM - 2; i >= 0; i--) {
    const int chl = 2 * i + 1, chr = 2 * i + 2;
    buf[i] = min(buf[chl], buf[chr]);
  }
}

long st_query_r(long queryb, long querye, long cur, long curb, long cure) {
  if (curb >= querye || cure <= queryb) {  // no intersection
    return INF;
  } else if (queryb <= curb && cure <= querye) {  // inclusion
    return buf[cur];
  } else {
    const long m = (curb + cure) / 2, chl = 2 * cur + 1, chr = 2 * cur + 2;
    return min(st_query_r(queryb, querye, chl, curb, m),
               st_query_r(queryb, querye, chr, m, cure));
  }
}

long st_query(long queryb, long querye) {
  return st_query_r(queryb, querye, 0, 0, NUM_ELEM);
}

long solve(const long *as, long b, long e) {
  if (e - b == 0) {
    return 0;
  } else if (e - b == 1) {
    return as[b];
  }
  // find smallest value in range
  long a_min = st_query(b, e), i_min = revs[a_min];
  return a_min * (i_min - (b - 1)) * (e - i_min) + solve(as, b, i_min) +
         solve(as, i_min + 1, e);
}

int main(int argc, char *argv[]) {
  // read inputs
  long N, as[MAX_N];
  scanf("%ld", &N);
  for (int i = 0; i < N; i++) {
    scanf("%ld", &as[i]);
  }

  // create reverse map
  for (int i = 0; i < N; i++) {
    revs[as[i]] = i;
  }

  // solve
  st_init(as, N);
  printf("%ld\n", solve(as, 0, N));

  return 0;
}


Measured memory_bytes: 45440
N,M = map(int,input().split())

if N == 1 and M == 1:
    print (1)

elif N == 1 or M == 1:
    print (max(N,M)-2)

elif N == 2 or M == 2:
    print (0)
    
else:
    print ((N-2)*(M-2))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  long long n,m,ans;
  cin>>n>>m;
  ans=(n<m/2?n+(m-2*n)/4:m/2);
  cout<<ans;
}

Measured memory_bytes: 256
str = raw_input()
str1 = raw_input()
N,k = map(int, str.split())
array = map(int, str1.split())

INF = 10**10
answer = INF

for i in range(N-k+1):
    answer = min(answer, array[i+k-1]-array[i]+min(abs(array[i+k-1]), abs(array[i])))

print answer


Measured memory_bytes: 12264
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <map>
#include <utility>
#include <set>
#include <climits>

using namespace std;

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

int main() {
    int N;
    scanf("%d", &N);
    int prev = INT_MAX;
    int max_move = 0, cnt = -1;
    for (int i = 0; i < N; ++i) {
        int h;
        scanf("%d", &h);
        if (h <= prev) {
            ++cnt;
        } else {
            cnt = 0;
        }
        prev = h;
        max_move = max(max_move, cnt);
    }
    printf("%d\n", max_move);
    return 0;
}



Measured memory_bytes: 256
from operator import itemgetter
n=int(input())
ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort(key=itemgetter(1,0))
time=0
ans='Yes'
for i in range(n):
  time+=ab[i][0]
  if time>ab[i][1]:
    ans='No'
    break
print(ans)

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

using namespace std;

char a[51][51];
int n,m;

bool valid(int i, int j){
    if(i-1>=0){
        if(a[i-1][j]=='#')
            return true;
    }
    if(i+1<=n-1){
        if(a[i+1][j]=='#')
            return true;
    }
    if(j+1<=m-1){
        if(a[i][j+1]=='#')
            return true;
    }

    if(j-1>=0){
        if(a[i][j-1]=='#')
            return true;
    }
    return false;
}

int main(){
    ios::sync_with_stdio(false);
    int ans=0;
    cin>>n>>m;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < m; ++j){
            cin>>a[i][j];
        }
    }


    for(int i = 0; i < n; ++i){
        for(int j = 0; j < m; ++j){
            if(a[i][j]=='#'){
                if(!valid(i, j)){
                    cout<<"No"<<endl;
                    return 0;
                }
            }
        }
    }


    cout<<"Yes";
    cout<<endl;


    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Convert;
using static System.Console;
using static System.Math;
class MainClass
{
	static void Main(string[] args)
	{
		Answer(new ConsoleInput(Console.In, ' '));
	}
	public static void Answer(ConsoleInput cin)
	{
			const string STRPOS = "POSSIBLE";
			const string STRIMP = "IMPOSSIBLE ";

			int[] arr = cin.ReadIntArray(2);
			var N = arr[0];
			var M = arr[1];

			var f = new int[M];
			var t = new int[M];
			for (int i = 0; i < M; i++)
			{
				f[i] = cin.ReadInt;
				t[i] = cin.ReadInt;
			}

			var bf = new bool[200001];
			var bt = new bool[200001];
			for (int i = 0; i < M; i++)
			{
				if (f[i] == 1)
					bt[t[i]] = true;
				if (t[i] == N)
					bf[f[i]] = true;
			}

			for(int i = 1; i <= N; i++)
			{
				if (bf[i] && bt[i])
				{
					WriteLine(STRPOS);
					return;
				}
			}
			WriteLine(STRIMP);      
	}
  
    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

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

int main() {
  int N, M, sum, cond, count;
  sum = 0;
  count = 0;
  cin >> N >> M;
  
  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A[i];
    sum += A[i];
  }
  cond = sum /(4*M) ;
  
  for(int i = 0; i < N; i++){
    if(A[i]*4*M >= sum ){
      count++;
    }
  }
  
  if(count >= M) cout << "Yes" << endl;
  else cout << "No" << endl;

}


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

using namespace std;

const int MAXN = 1e3 + 10;

int n;
string s, t;

int main(){
	cin >> n >> s >> t;
	for (int i = n; i <= n + n; i++){
		int common = n+n - i;
		bool fail = 0;
		for (int j = n - common; !fail && j < n; j++)
			fail |= s[j] != t[j - (n - common)];

		if (!fail){
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}


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

int a,b;

int main() {
    while(1){
        cin>>a>>b;
        if(a==0 && b==0) break;
        rep(i,a){
            rep(j,b){
                if((i>0 && i<a-1) && (j>0 && j<b-1)) cout << ".";
                else cout <<"#";
            }
            cout << endl;
        }
        cout << endl;
    }
    
    return 0;
    
   
}



Measured memory_bytes: 3080
import java.util.*;
import java.io.*; 
import java.math.BigInteger;
import java.text.*;
//Solution Credits: Taranpreet Singh
public class Main{
    //SOLUTION BEGIN
    void solve(int TC) throws Exception{
        int n = ni(), k = ni();
        BigInteger ans = BigInteger.valueOf(n/k), tmp = BigInteger.ZERO;
        ans = ans.pow(3);
        if(k%2==0){
            tmp = BigInteger.valueOf((n+k/2)/k);
            ans = ans.add(tmp.pow(3));
        }
        pn(ans.toString());
    }
    //SOLUTION ENDS
    long mod = (int)1e9+7, IINF = (long)1e18;
    final int MAX = (int)1e5+1, INF = (int)1e9, root = 3;
    DecimalFormat df = new DecimalFormat("0.00000000");
    double PI = 3.141592653589793238462643383279502884197169399375105820974944, eps = 1e-8;
    static boolean multipleTC = false, memory = true;
    FastReader in;PrintWriter out;
    void run() throws Exception{
        in = new FastReader();
        out = new PrintWriter(System.out);
        int T = (multipleTC)?ni():1;
        //Solution Credits: Taranpreet Singh
        for(int i = 1; i<= T; i++)solve(i);
        out.flush();
        out.close();
    }
    public static void main(String[] args) throws Exception{
        if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, "1", 1 << 28).start();
        else new Main().run();
    }
    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}
    void p(Object o){out.print(o);}
    void pn(Object o){out.println(o);}
    void pni(Object o){out.println(o);out.flush();}
    String n(){return in.next();}
    String nln(){return in.nextLine();}
    int ni(){return Integer.parseInt(in.next());}
    long nl(){return Long.parseLong(in.next());}
    double nd(){return Double.parseDouble(in.next());}

    class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

        String next(){
            while (st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (IOException  e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine(){
            String str = "";
            try{    
                str = br.readLine();
            }catch (IOException e){
                e.printStackTrace();
            }   
            return str;
        }
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")

#define rep(i,n) for(int i=0;i<n;i++)
const long long MOD = 1000000007;
typedef pair<int,int> P;
typedef long long ll;

ll n,m,k,ans;
string s;

int main(){
  cin >> n;
  unordered_map<int,int> mp;
  ans = 0;
  rep(i,n){
    cin >> m;
    mp[m]++;
  }
  for(auto i = mp.begin(); i != mp.end(); i++){
    if( (i->second) % 2 ) ans++;
  }
  cout << ans << "\n";
}

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

int main() {
	string a, b, c; cin >> a >> b >> c;
	if(a[a.size()-1]==b[0] && b[b.size()-1]==c[0]) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


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

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

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;

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

    int h, w;
    cin >> h >> w;
    vector<vector<char>> s(h+2, vector<char>(w+2, ' '));
    vector<vector<char>> ans(h+2, vector<char>(w+2, '0'));

    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            cin >> s[i][j];
        }        
    }

    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            if(s[i][j] == '.'){
                if(s[i][j+1] == '#') ans[i][j]++;
                if(s[i][j-1] == '#') ans[i][j]++;
                if(s[i+1][j+1] == '#') ans[i][j]++;
                if(s[i-1][j+1] == '#') ans[i][j]++;
                if(s[i+1][j-1] == '#') ans[i][j]++;
                if(s[i-1][j-1] == '#') ans[i][j]++;
                if(s[i+1][j] == '#') ans[i][j]++;
                if(s[i-1][j] == '#') ans[i][j]++;
            }
            if(s[i][j] == '#') ans[i][j] = '#';
        }        
    }


    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            cout << ans[i][j];
        }
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String name[] = {"black","blue","lime","aqua","red","fuchsia","yellow","white"};
		int color[][] = {{0,0,0},{0,0,255},{0,255,0},{0,255,255},{255,0,0},{255,0,255},{255,255,0},{255,255,255}};
		while(sc.hasNext()){
			String str = sc.next();
			if(str.equals("0")){
				break;
			}
			int R = Integer.parseInt(str.substring(1,3),16);
		    int G = Integer.parseInt(str.substring(3,5),16);
		    int B = Integer.parseInt(str.substring(5,7),16);
		    double min = Double.MAX_VALUE;
		    int index = 0;
		    for(int i=0;i<8;i++){
		    	double near = Math.sqrt(Math.pow(R - color[i][0],2) + Math.pow(G - color[i][1],2) + Math.pow(B - color[i][2],2));
		    	if(min > near){
		    		min = near;
		    		index = i;
		    	}
		    }
			System.out.println(name[index]);
		}
	}
}



Measured memory_bytes: 31964
N,M = map(int,input().split())
INF = 10 ** 10
dp = [INF] * (2 ** N)
dp[0] = 0

for i in range(M):
  a,b = map(int,input().split())
  c = list(map(int,input().split()))
  key = 0
  for j in range(len(c)):
    key += (1 << (c[j] - 1))
  for j in range(len(dp) - 1, -1, -1):
    if dp[j] == INF:
      continue
    dp[j | key] = min(dp[j | key], dp[j] + a)

print((dp[-1], -1)[dp[-1] == INF])

Measured memory_bytes: 9172
import math
a, b = [int(x) for x in input().split()]

price = math.ceil(a * 100 / 8)
if math.floor(price * 0.1) == b:
  print(price)
else:
  price = int(b * 100 / 10)
  if math.floor(price * 0.08) == a:
    print(price)
  else:
    print(-1)

Measured memory_bytes: 3188
# 全体から引く？全体がわからん わかるの？
# abcd -> [abcd, bacd, cbad, dcba, acbd, adcb, abdc] で7
# aattはaaとttが回分になるのでそれを引いて5？
# abc -> [abc, bac, cba, acb]
# abracadabra 11文字
# 1 + 2 + .. + n - 1 = n*(n-1)/2 3文字だと3で、これにもとのやつを足して4
# 4文字だと4*3/2 + 1 = 6 + 1 = 7
# 11文字だと11*10/2 + 1 = 56 あってそう
# maxだと2 * 10^5 せいぜい19999900000
# arbacadabra を構成する方法が2通りあるということだが？？？？
# （abracadabra がオリジナル）
# たしかに 偶数からなる場合は abraとbrをの2パターンある
# 両端が同じで長さが偶数ならたしかにそうなる
# しかし両端が同じなら、というのならば奇数でも同じではないか？
# -> つまり、同じ文字に挟まれたところはすべて該当するのではないか？
# abracadabraでは {'a': 5, 'b': 2, 'r': 2, 'c': 1, 'd': 1} で、同じ文字で2つえらぶとすると a = 5*4/2 = 10, b = 1, r = 1
# これを足して全体から引くと答えになりそう
s = list(input())
d = {}
for c in s:
    if c not in d:
        d[c] = 1
    else:
        d[c] += 1
ans = len(s) * (len(s) - 1) // 2 + 1
for v in d.values():
    ans -= v * (v - 1) // 2
print(ans)

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

using namespace std;
typedef long long ll;

string s;
ll memo[2][2019];

int main(){
    cin >> s;
    ll sum = 0;
    for(int i=0;i<2019;i++) memo[0][i] = 0;
    memo[0][s[0]-'0']++;
    for(int i=1;i<s.size();i++){
        for(int j=0;j<2019;j++) memo[1][j] = 0;
        memo[1][s[i]-'0']++;
        for(int j=0;j<2019;j++) memo[1][((j*10)+ (s[i]-'0'))%2019] += memo[0][j];
        sum += memo[1][0];
        for(int j=0;j<2019;j++) memo[0][j] = memo[1][j];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3796
//
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000
#define PI 3.14159265
#define EPS 1e-9
#define Pi acos(-1.0)
typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;

/*CODE START HERE*/

string n;
int times[30];
bool ans;

int main(){
    ios::sync_with_stdio(0);
    cin >> n;
    clean(times,0);
    forn(i, n.size()){
        times[n[i]-'a']++;
    }
    ans = true;
    forn(i,30){
        if(times[i]%2){
            ans = false;
            break;
        }
    }

    if(ans){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <bitset>
#include <stack>
//#include <atcoder/scc>
//#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
//using namespace atcoder;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)

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;
    }
}

lli gcd2(lli x, lli y)
{
    lli t;
    while (y != 0)
        t = x % y, x = y, y = t;
    return (x);
}

lli lcm2(lli x, lli y)
{
    lli xy = x * y;
    if (xy < 0)
        xy = -xy;
    return (xy / gcd2(x, y));
}

int main(void)
{
    int x;
    cin >> x;
    if (x == 1)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 3620
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	aa := make([]int, n)
	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner)
	}
	q := getNextInt(scanner)
	for i := 0; i < q; i++ {
		k := getNextInt(scanner)
		l := -1
		r := n
		for l+1 < r {
			m := (l + r) >> 1
			if aa[m] < k {
				l = m
				continue
			}
			r = m
		}
		fmt.Fprintln(writer, r)
	}
}



Measured memory_bytes: 5912
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]

dicts = {}
small = 0
for i in s:
    if i not in dicts.keys():
        dicts[i] = 1
    else:
        dicts[i] += 1
    
for i in t:
    if i not in dicts.keys():
        dicts[i] = -1
    else:
        dicts[i] -= 1

tmp = max(dicts.values())
print(max(tmp, small))


Measured memory_bytes: 3064
from functools import reduce

def egcd(a, b):
    if a == 0:
        return (b, 0, 1)
    else:
        g, y, x = egcd(b % a, a)
        return (g, x - (b // a) * y, y)

# mを法とするaの乗法的逆元
def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m

MOD = 10**9+7

N,M,K = map(int,input().split())

patterns = reduce(lambda a,b: (a*b)%MOD, range(N*M-K+1, N*M+1))
patterns *= modinv(reduce(lambda a,b: (a*b)%MOD, range(1, K+1)), MOD)

patterns *= (N+M)*K*(K-1)
patterns *= modinv(6, MOD)
patterns %= MOD

print(patterns)

Measured memory_bytes: 3572
## constant

MOD = 10000

### subroutines

def count_rec(m, b0, b1)
  return 1 if m >= $n
  return $crcache[m][b0][b1] if ! $crcache[m][b0][b1].nil?

  count = 0

  for b in (0..2)
    if ($abs[m].nil? || $abs[m] == b) && (b != b0 || b != b1)
      count = (count + count_rec(m + 1, b1, b)) % MOD
    end
  end

  $crcache[m][b0][b1] = count
end

### main

$n, k = gets.strip.split(' ').map{|s| s.to_i}

$abs = []

k.times do
  ai, bi = gets.strip.split(' ').map{|s| s.to_i - 1}
  $abs[ai] = bi
end

$crcache = $n.times.map{3.times.map{[]}}

count = 0

for i in (0..2)
  next if ! $abs[0].nil? && $abs[0] != i

  for j in (0..2)
    next if ! $abs[1].nil? && $abs[1] != j

    count = (count + count_rec(2, i, j)) % MOD
  end
end

puts count

Measured memory_bytes: 6260
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mod 1000000007
#define pi (3.141592653589)
#define deb(n) cerr << #n << " = " << (n) << " ";
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout << fixed;
	cout.precision(10);

	const int N = 1e5 + 10;
	int n;
	cin >> n;
	int a[n];
	vector<int> used(N);
	long long sol = 0;
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
		sol += a[i];
		used[a[i]]++;
	}
	int q;
	cin >> q;
	while(q--)
	{
		int x, y;
		cin >> x >> y;
		if(used[x] > 0)
		{
			sol -= used[x] * 1ll * x;
			sol += used[x] * 1ll * y;
			used[y] += used[x];
			used[x] = 0;
		}
		cout << sol << "\n";
	}

	return 0;
}


Measured memory_bytes: 3960
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln = '\n';

const int mx=100010;
const ll mod=1e9+7;


int main(){
  int n,k;
  cin >> n >> k;
  vector<int> a(n+1,0);
  rep(i,n){
    cin >> a[i+1];
  }
  vector<vector<ll>> dp(310, vector<ll>(310,longinf));
  dp[0][0]=0;
  for(int i=1; i<=n; i++)rep(j,n-k){
    ll tmp = longinf;
    rep(l,i){
      tmp = min(tmp, dp[l][j] + max(0,a[i]-a[l]));
    }
    dp[i][j+1] = tmp;
  }
  ll ans = longinf;
  REP(i,n-k,n+1){
    ans = min(ans, dp[i][n-k]);
  }
  cout << ans << ln;
  return 0;
}

Measured memory_bytes: 1024
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
A = [int(sys.stdin.readline()) for _ in range(N)]

s = set()
for a in A:
    if a in s:
        s.remove(a)
    else:
        s.add(a)
print(len(s))


Measured memory_bytes: 23360
#include<stdio.h>

int main(){
	int i,count;
	int a[3];
	scanf("%d%d%d",&a[0], &a[1], &a[2]);
	count=0;
	for(i=0;i<=2;i++){
		if(a[i]==5){
			count+=1;
		}
		else if(a[i]==7){
			count+=2;
		}
		else{
			count+=100;
		}
	}
	if(count==4){
		printf("YES");
	}
	else{
		printf("NO");
	}
}


Measured memory_bytes: 128
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	boolean[][][] ft = new boolean[2][5][7];

	class State implements Comparable<State> {
		int i;
		int j;
		int foot;
		int cost;

		State(int i, int j, int foot, int cost) {
			this.i = i;
			this.j = j;
			this.foot = foot;
			this.cost = cost;
		}

		@Override
		public int compareTo(State arg0) {
			return this.cost - arg0.cost;
		}
	}

	class ij {
		int i;
		int j;

		ij(int i, int j) {
			this.i = i;
			this.j = j;
		}

		public boolean equals(Object obj) {
			return ((ij) obj).i == i && ((ij) obj).j == j;
		}
	}

	void run() {
		ft[0][0][4] = true;
		ft[0][1][4] = true;
		ft[0][1][5] = true;
		ft[0][2][4] = true;
		ft[0][2][5] = true;
		ft[0][2][6] = true;
		ft[0][3][4] = true;
		ft[0][3][5] = true;
		ft[0][4][4] = true;
		for (int i = 0; i < 5; i++) {
			for (int j = 0; j < 7; j++) {
				ft[1][i][j] = ft[0][i][6 - j];
			}
		}

		for (;;) {
			int w = sc.nextInt();
			int h = sc.nextInt();
			if ((w | h) == 0) {
				break;
			}
			int[][] map = new int[h + 4][w + 6];

			int[][][] cost = new int[h + 4][w + 6][2];
			for (int i = 0; i < cost.length; i++) {
				for (int j = 0; j < cost[i].length; j++) {
					cost[i][j][0] = Integer.MAX_VALUE >> 2;
					cost[i][j][1] = Integer.MAX_VALUE >> 2;
				}
			}

			LinkedList<ij> goal = new LinkedList<ij>();
			PriorityQueue<State> Q = new PriorityQueue<State>();
			for (int i = 2; i < h + 2; i++) {
				for (int j = 3; j < w + 3; j++) {
					if (sc.hasNextInt()) {
						map[i][j] = sc.nextInt();
					} else {
						String a = sc.next();
						if (a.equals("S")) {
							map[i][j] = -2;
							Q.add(new State(i, j, 0, 0));
							Q.add(new State(i, j, 1, 0));
							cost[i][j][0] = 0;
							cost[i][j][1] = 0;
						}
						if (a.equals("T")) {
							map[i][j] = -3;
							goal.add(new ij(i, j));
						}
					}
				}
			}

			int ans = -1;
			for (; !Q.isEmpty();) {
				State s = Q.poll();

				if (goal.contains(new ij(s.i, s.j))) {
					if (ans == -1 ||ans > s.cost) {
						ans = s.cost;
					}
					continue;
				}

				if (s.cost < cost[s.i][s.j][s.foot]) {
					continue;
				}

				for (int i = 0; i < 5; i++) {
					for (int j = 0; j < 7; j++) {
						if (ft[s.foot ^ 1][i][j]) {
							int mvalue = map[s.i + i - 2][s.j + j - 3];
							if (mvalue == 0) {
								continue;
							}
							if (mvalue < 0) {
								mvalue = 0;
							}
							if (cost[s.i + i - 2][s.j + j - 3][1 - s.foot] > s.cost
									+ mvalue) {
								cost[s.i + i - 2][s.j + j - 3][1 - s.foot] = s.cost
										+ mvalue;
								Q.add(new State(s.i + i - 2, s.j + j - 3,
										1 - s.foot, cost[s.i + i - 2][s.j + j
												- 3][1 - s.foot]));
							}
						}
					}
				}
			}
			System.out.println(ans);
		}

	}

	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}
}

Measured memory_bytes: 15000
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
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;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 

vll dp(100100);

ll sum(ll n) {
ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}


 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  st s;
    ci(s);
  ll n=s.sz;
  vst A(n*(n+1)/2);

  ll now=0;
  FOR(i,0,n){
    FOR(j,1,n-i+1){
      A[now]=s.substr(i,j);
      now++;
    }
  }

  ll ans=0;
  FOR(i,0,n*(n+1)/2){
    ll a=A[i].sz;
    bl b=true;
    FOR(j,0,a){
      if(A[i][j]!='A'&&A[i][j]!='C'&&A[i][j]!='G'&&A[i][j]!='T'){
        b=false;
      }
    }
    if(b){
      chmax(ans,a);
    }
  }
  co(ans)
}

Measured memory_bytes: 1024
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

immutable long MOD = 10^^9 + 7;

long powmod(long a, long x, long m) {
    long ret = 1;
    while (x) {
        if (x % 2) ret = ret * a % m;
        a = a * a % m;
        x /= 2;
    }
    return ret;
}

long count(int x) {
    return ((powmod(10, x, MOD) - powmod(10, x-1, MOD)) % MOD + MOD) % MOD;
}

void main() {
    auto S = readln.chomp.to!int;
    long ans = 0;

    // f(l) <= 7
    {
        auto A = new int[](10^^7*5);
        for (int k = 1; k <= 8; ++k) {
            for (int i = 10^^(k-1); i < 10^^k && i < 10^^7*5; ++i) {
                A[i] = k;
            }
        }

        for (int l = 1, r = 1, cnt = 0; l < 10^^7; cnt -= A[l], l += 1) {
            if (r < l) r = l, cnt = 0;
            while (cnt < S) cnt += A[r], r += 1;
            if (cnt == S) (ans += 1) %= MOD;
        }
    }

    // f(l) >= 8
    {
        int[] factors;
        int T = S / 8;

        for (int i = 1; i * i <= S; ++i) {
            if (S % i != 0) continue;
            if (i * i != S) factors ~= S / i;
            factors ~= i;
        }

        foreach (f; factors) {
            if (S / f < 8) continue;
            (ans += count(S / f) - f) %= MOD;
            ans = (ans + MOD) % MOD;
        }

        (ans += T) %= MOD;
    }

    ans.writeln;
}

Measured memory_bytes: 197884
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    int n;
    cin >> n;
    bool can = 0;
    rep(i, n+1) {
        if(100*i <= n && 105*i >= n) can = 1;
    }
    if(can) cout << 1 << endl;
    else cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 3636
a, b, x = gets.split.map(&:to_f)
room = a*a*b-x
if room <= a*a*b/2
	p 90-Math.atan(a*a*a/2/room)*180/Math::PI
else
	p 90-Math.atan(2*x/b/b/a)*180/Math::PI
end


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

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

int main(){
  int n,m;
  cin >> n >> m;
  int A[101][101];
  int B[101];
  rep(i,n){
    rep(j,m){
      cin >> A[i][j];
    }
  }
  rep(j,m){
    cin >> B[j];
  }
  rep(i,n){
    int c = 0;
    rep(j,m){
      c += A[i][j]*B[j];
    }
    cout << c << endl;
  }
}



Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

string start[4] = {
	"SS",
	"SW",
	"WS",
	"WW"
};

int main() {
	int N;
	cin >> N;
	string s;
	cin >> s;
	for (int i = 0; i < 4; i++) {
		string animals = start[i];
		for (int j = 1; j < N - 1; j++) {
			if (animals[j] == 'S') {
				if (s[j] == 'o')animals += animals[j - 1];
				else {
					if (animals[j - 1] == 'W')animals += 'S';
					else animals += 'W';
				}
			}
			else {
				if(s[j] == 'x')animals += animals[j - 1];
				else {
					if (animals[j - 1] == 'W')animals += 'S';
					else animals += 'W';
				}
			}
		}

		bool flag = false;
		if (s[N - 1] == 'o') {
			if ((animals[N - 1] == 'S' && animals[N - 2] == animals[0]) ||
				(animals[N - 1] == 'W' && animals[N - 2] != animals[0])) {
				flag = true;
			}
		}
		else {
			if ((animals[N - 1] == 'W' && animals[N - 2] == animals[0]) ||
				(animals[N - 1] == 'S' && animals[N - 2] != animals[0])) {
				flag = true;
			}
		}
		if (flag) {
			if (s[0] == 'o') {
				if ((animals[0] == 'S' && animals[N - 1] == animals[1]) ||
					(animals[0] == 'W' && animals[N - 1] != animals[1])) {
					cout << animals << endl;
					return 0;
				}
			}
			else {
				if ((animals[0] == 'W' && animals[N - 1] == animals[1]) ||
					(animals[0] == 'S' && animals[N - 1] != animals[1])) {
					cout << animals << endl;
					return 0;
				}
			}
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main() {
  char S[5];
  scanf("%s", S);
  int head = ((int)S[0]-'0')*10 + ((int)S[1]-'0');
  int tail = ((int)S[2]-'0')*10 + ((int)S[3]-'0');
  if (head >= 1 && head <= 12) {
    if (tail >= 1 && tail <= 12) {
      printf("AMBIGUOUS\n");
    } else {
      printf("MMYY\n");
    }
  } else {
    if (tail >= 1 && tail <= 12) {
      printf("YYMM\n");
    } else {
      printf("NA\n");
    }
  }
  return 0;
}


Measured memory_bytes: 128
abcd = input()
a = int(abcd[0])
b = int(abcd[1])
c = int(abcd[2])
d = int(abcd[3])

ans_list = [[0 for _ in range(8)] for __ in range(3)]

ans_list[0][0] = a + b
ans_list[0][1] = a - b
for i in range(2):
    ans_list[1][i * 2] = ans_list[0][i] + c
    ans_list[1][i * 2 + 1] = ans_list[0][i] - c
for i in range(4):
    ans_list[2][i * 2] = ans_list[1][i] + d
    ans_list[2][i * 2 + 1] = ans_list[1][i] - d

for n in range(8):
    if ans_list[2][n] == 7:
        ans = ""
        ans += abcd[0]
        if n > 3:
            ans += "-"
        else:
            ans += "+"
        ans += abcd[1]
        if n == 0 or n == 1 or n == 4 or n == 5:
            ans += "+"
        else:
            ans += "-"
        ans += abcd[2]
        if n % 2 == 0:
            ans += "+"
        else:
            ans += "-"
        ans += abcd[3]
        ans += "=7"
        print(ans)
        break

Measured memory_bytes: 3064
n, k = [int(i) for i in input().split()]
r, s, p = [int(i) for i in input().split()]
t = input()
a = {"r": p, "s": r, "p": s}
b = {"r": "p", "s": "r", "p": "s"}

ans = 0
u = ""
for i in t:
    if len(u)<k:
        ans += a[i]
        u+=b[i]
    elif u[-k] == b[i]:
        u+="1"
        ans += 0
    else:
        ans += a[i]
        u += b[i]

print(ans)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
#define r0 return 0
#define INF (int)1e15
#define MOD 1000000007

 int main(){

 long long n,c=0,ans=0;
 cin>>n;

  int v[n];

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

    for(int i=1;i<n;i++){

        if(v[i] <=v[i-1])
            ++c;
        else
            c = 0;

      ans = max(ans,c);
    }

  cout<<ans<<endl;

 return 0;
 }


Measured memory_bytes: 4028
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  int a[n];
  rep(i, 0, n) a[i] = 0;
  rep(i, 0, n - 1) {
    int x;
    cin >> x;
    a[x - 1]++;
  }
  rep(i, 0, n) { cout << a[i] << endl; }
}


Measured memory_bytes: 4428
#include<iostream>

using namespace std;

int p[10000];

int main(){
	int n=1;
    p[0]=2;
	for(int x=3;x<100010;x+=2){
      bool f=true;
    	for(int j=0;j<n;j++){
        	if(x%p[j]==0){
            	f= false;
              	break;
            }
        }
      if(f){
        p[n]=x;
      	n++;
      }
    }
  int X;
  cin>>X;
  for(int i =0;i<n;i++){
    if(p[i]>=X){
      cout << p[i]<<endl;
      return 0;
    }
  }
  cout << n<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

	int i, j=0;
	int x, m;
	char a[201];			/* ?????????????????????200????¶?????????? */
	char b[101][201];		/* ?????£?????????????????°???100????¶?????????? */

	while(1){

		scanf("%s", a);		/* ?????°???????????????????????\??? */

		if(a[0] == '-'){	/* ????????????????????¨???????????????"-"?????¨?????\????????? */
			break;
		}

		scanf("%d", &m);
         
		for(i=0; i<m; i++){

		scanf("%d", &x);
		strcpy(b[j], a+x);
		strncat(b[j], a, x);
		strcpy(a, b[j]);

		}					/* ??????????????¨??????????????? */

		j++;
	}
	for(i=0; i<j; i++){		/* ?????????????????????????????????????????????????????????????????? */

	printf("%s\n", b[i]);
	}

	return 0;
}

Measured memory_bytes: 608