akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
#include <stack>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}

int h,w,n;

void drop(vector<string> &v){
    for(int i=0;i<w;i++){
        vector<char> vv;
        for(int j=0;j<h;j++){
            if(v[j][i]!='.')vv.push_back(v[j][i]);
        }
        for(int j=0;j<h;j++){
            if(j<vv.size()){
                v[j][i]=vv[j];
            }
            else{
                v[j][i]='.';
            }
        }
    }
}

bool solve(vector<string> &s){
    drop(s);
    bool update=false;
    vector<vector<bool>> used(h,vector<bool>(w,false));
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]!='.'){
                int cnt=0;
                for(int k=j;k<w;k++){
                    if(s[i][k]==s[i][j])cnt++;
                    else break;
                }
                if(cnt>=n){
                    for(int k=j;k<j+cnt;k++){
                        used[i][k]=true;
                    }
                }
                cnt=0;
                for(int k=i;k<h;k++){
                    if(s[k][j]==s[i][j])cnt++;
                    else break;
                }
                if(cnt>=n){
                    for(int k=i;k<i+cnt;k++){
                        used[k][j]=true;
                    }
                }
            }
        }
    }
    bool res=true;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]!='.')res=false;
            if(used[i][j]){
                s[i][j]='.';
                update=true;
            }
        }
    }
    if(update){
        drop(s);
        res=solve(s);
    }
    return res;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> h >> w >> n;
    vector<string> s(h);
    for(int i=0;i<h;i++){
        cin >> s[i];
    }
    reverse(s.begin(), s.end());
    for(int i=0;i<h;i++){
        for(int j=0;j+1<w;j++){
            auto s2=s;
            swap(s2[i][j],s2[i][j+1]);
            if(solve(s2)){
                printf("YES\n");
                return 0;
            }
        }
    }
    printf("NO\n");
}



Measured memory_bytes: 3324
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 705
#define inf 1e9
#define eps 1e-10
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int n,m,mp[maxn][maxn],cnt,vis[maxn],col[maxn],f;
int t[maxn][2],dp[maxn][maxn];

inline void dfs(int u)
{
	t[cnt][col[u]]++; vis[u]=1;
	for(int i=1;i<=n;i++)
	{
		if(i==u) continue;
		if(mp[u][i]==0&&vis[i]==0) col[i]=col[u]^1,dfs(i);
		else if(mp[u][i]==0&&col[i]==col[u]) {f=1; return;}
	}
}

inline int cal(int x,int y){return x*(x-1)/2+y*(y-1)/2;}

int main()
{
	n=read(); m=read();
	for(int i=1;i<=m;i++) {int u=read(),v=read(); mp[u][v]=mp[v][u]=1;}
	for(int i=1;i<=n;i++) if(!vis[i]) cnt++,dfs(i); dp[0][0]=1;
	for(int i=1;i<=cnt;i++)
	{
		for(int j=0;j<=n;j++)
		{
			dp[i][j+t[i][0]]|=dp[i-1][j];
			dp[i][j+t[i][1]]|=dp[i-1][j];
		}
	}
	int ans=inf;
	for(int i=1;i<=n;i++) if(dp[cnt][i]) ans=min(ans,cal(i,n-i));
	if(f==1) puts("-1"); else cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,a;
    long long int sum=0;
    cin>>n;
    for (int i=0;i<n;i++) {
        cin>>a;
        sum+=a;
    }
    long long int ave=sum/n;
    cout<<ave<<endl;
}


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

int main(){
    int n;
    scanf("%d",&n);
    int a[1000];
    for(int i = 0;i < n;i++){
        scanf("%d",&a[i]);
    }

    int flag = 0;
    for(int i = 0;i < n;i++){
        if(a[i]%2 == 0){
            if(a[i]%3 == 0 || a[i]%5 == 0) continue;
            flag = 1;
        }
    }

    if(flag == 0){
        printf("APPROVED");
    }else{
        printf("DENIED");
    }
    return 0;
}


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

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

#define MAX_V 15
#define MAX_D 1000
#define SUP (MAX_V * MAX_D + 1)
int V, E;
int d[MAX_V][MAX_V];
int memo[1<<MAX_V][MAX_V]; // nodes already walked * current node

int recur(int s, int v) {
    if (memo[s][v] != SUP) return memo[s][v];
    if (s == (1<<V)-1 and v == 0) return memo[s][v] = 0;
    int result = SUP+1;
    repeat (i,V) if (not (s&1<<i)) if (d[v][i] < SUP) {
        result = min(result, d[v][i] + recur(s|1<<i,i));
    }
    return memo[s][v] = result;
}

int main() {
    cin >> V >> E;
    repeat (i,V) repeat (j,V) d[i][j] = SUP;
    repeat (i,E) { int a, b; cin >> a >> b; cin >> d[a][b]; } // there are no multiedge
    repeat (i,1<<V) repeat (j,V) memo[i][j] = SUP;
    cout << (recur(0,0) < SUP ? recur(0,0) : -1) << endl;
    return 0;
}

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

int main(){

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

Measured memory_bytes: 3056
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(' ').map(String::toInt)
    val box = Array(n) { 0 }
    for (i in n downTo 1) {
        var po = 0
        for (j in 2..(n / i)) {
            po += box[j * i - 1]
        }
        box[i - 1] = (po + a[i - 1]) % 2
    }
    var count = 0
    var ans = emptyList<Int>().toMutableList()
    for (i in 0 until n) {
        if (box[i] == 1) {
            count++
            ans.add(i + 1)
        }
    }
    println(count)
    println(ans.joinToString(" "))
}


Measured memory_bytes: 81844
# https://atcoder.jp/contests/abc129/tasks/abc129_c

MOD = 1_000_000_007

N, M = gets.split.map(&:to_i)

diffs = []
player_position = 0
M.times do
  broken_position = gets.to_i

  diffs << broken_position - 1 - player_position
  player_position = broken_position + 1
end
diffs << N - player_position

if diffs.min < 0
  puts 0
  exit
end

route_count_by_diff = [1, 1, 2]
(3..(diffs.max)).each do |i|
  route_count_by_diff << route_count_by_diff[i - 1] + route_count_by_diff[i - 2]
end

route_count = 1
diffs.each do |diff|
  route_count *= route_count_by_diff[diff]
end

puts route_count % MOD


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

typedef long long ll;
typedef long double ld;
typedef vector < ll > vl;
typedef vector < int > vi;
typedef vector < bool > vb;
typedef vector < vl > vvl;
typedef vector < vi > vvi;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
typedef vector < pll > vpll;
typedef vector < pii > vpii;
typedef vector < vpll > vvpll;
typedef vector < vpii > vvpii;

#define pb push_back
#define eb emplace_back
#define pf push_front
#define all(c) (c).begin(), (c).end()
#define ff first
#define ss second
#define mp(x,y) make_pair((x), (y))
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL)



void solve(){
    
    ll n, d; cin >> n >> d;
    ll cnt = 0;
    for(ll i = 1; i <= n; i++){
        ll x, y; cin >> x >> y;
        if(x * x + y * y <= d * d)
            cnt++;
    }
    cout << cnt << '\n';
    
}


int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    boost;

    int t = 1;
    // cin >> t;


    for(int i = 1; i <= t; i++){
        // cout << "Case #" << i << ": ";

        solve();

    }
    return 0;
}

Measured memory_bytes: 3656
X, K, D = map(int, input().split())

X = abs(X)
a = int(X/D)
ans = 0

if a>=K:
    ans = X-(D*K)
else:
    if K%2==0:
        if a%2==0: ans = X-(D*a)
        else: ans = X-(D*a)-D
    else:
        if a%2==0: ans = X-(D*a)-D
        else: ans = X-(D*a)

ans = int(abs(ans))
print(ans)


Measured memory_bytes: 9084
#include<iostream>
using namespace std;
int main() {
  int a;
  int b;
  int c;
  cin >> a >> b >> c;
  if(a < b && b < c) {
    cout << "Yes" << endl;
      } else {
    cout << "No" << endl;
  }
  return 0;
}
  


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long int ll;
typedef unsigned long long ull;
typedef std::vector<int> vi;
typedef std::vector<ll> vll;
typedef std::vector<vi > vvi;
typedef std::vector<vll > vvll;
typedef std::pair<int,int> ii;
typedef std::pair< ll, ll > lp;
typedef std::vector<ii> vii;
typedef std::vector<vii > vvii;


#define pb push_back 
#define PB pop_back
#define pf push_front
#define PF pop_front
#define mp make_pair
#define ub(a,b) upper_bound(all(a),b)
#define lb(a,b) lower_bound(all(a),b)
#define bs(a,b) binary_search(all(a),b)
#define mem(a,b) memset(a,b,sizeof(a))
#define in(a,n) f(i,0,n-1)cin>>a[i]
#define in1(a,n) f(i,1,n)cin>>a[i]
#define out(a,n) f(i,0,n-1)cout<<fixed<<setprecision(20)<<a[i]<<" ";cout<<"\n"
#define ff first
#define ss second
#define f(i,a,b) for (int i=a;i<=b;i++)
#define rf(i,a,b) for(int i=a;i>=b;i--)
#define rep(i,n) f(i,0,n-1)
#define clr(a) (a).clear()
#define rz resize
#define sqr(a) ((a) * (a))
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin() ,(a).rend()
#define endl '\n'

const int N=(int)1e5+5;

int h[N],dp[N];

int main(int argc, char const *argv[])
{
	crap;
	int n,k;
	cin>>n>>k;
	in1(h,n);
	//base cases of recursion
	dp[n]=0;
	for (int i=n-1;i>0;i--)
	{
		int ch=1000000007;
		for (int j=1;j<=k && i+j<=n;j++)
		{
			ch=min(ch,abs(h[i]-h[i+j])+dp[i+j]);
		}
		dp[i]=ch;
	}

	// f(i,1,n)
	// 	cout<<dp[i]<<" ";
	// cout<<endl;

	cout<<dp[1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main (void)
{
   int a,b,d,r;
   double f;
   scanf("%d %d",&a,&b);
   d=a/b;
   r=a%b;
   f=(double)a/(double)b;
   printf("%d %d %.5lf",d,r,f);
   return 0;
}

Measured memory_bytes: 640
#def print_path(prev, cost):
#    for i in range(len(prev)):
#        print("%d, prev = %d, cost = %d" %  (i, prev[i], cost[i]))

def get_path(start, goal, prev):
    path = []
    now = goal
    path.append(now)
    while True:
        path.append(prev[now])
        if prev[now] == start: break
        now = prev[now]
    path.reverse()
    return path

def search(glaph, start, goal):
    MAX_VAL = 10000000
    g_size = len(glaph)
    visited = [False] * g_size
    cost = [MAX_VAL] * g_size
    prev = [None] * g_size
    cost[start] = 0
    prev[start] = start
    now = start
    while True:
        min = MAX_VAL
        next = -1
        visited[now] = True
        for i in range(g_size):
            if visited[i]: continue
            if glaph[now][i]:
                tmp_cost = glaph[now][i] + cost[now]
                if cost[i] > tmp_cost:
                    cost[i] = tmp_cost
                    prev[i] = now
            if min > cost[i]:
                min = cost[i]
                next = i
        if next == -1: break
        now = next
    #print_path(prev, cost)
    return [get_path(start, goal, prev), cost[goal]]

N, M = list(map(int, input().split())) # 整数
c = []

for i in range(10):
    c.append(list(map(int, input().split())))

A = []
for i in range(N):
    A.append(list(map(int, input().split())))

truecost = [[0 for i in range(10)] for j in range(10)]
for i in range(10):
    for j in range(10):
        if i == j:
            truecost[i][j] = 0
        else:
            truecost[i][j] = search(c,i,j)[1]

ans=0
for i in range(N):
    for j in range(M):
        if A[i][j] == -1:
            continue
            
        ans = ans + truecost[A[i][j]][1]

print(ans)

Measured memory_bytes: 3444
n = int(input())
alist  = list(map(int,input().split()))
list1 = alist[1::2]
list2 = alist[0::2]
from collections import Counter
dic1 = Counter(list1).most_common()
dic2 = Counter(list2).most_common()
dic1.append([0,0])
dic2.append([0,0])
if dic1[0][0]!=dic2[0][0]:
  print(n - dic1[0][1] - dic2[0][1])
else:
  print(min(n - dic1[0][1] - dic2[1][1], n -dic1[1][1] - dic2[0][1]))

Measured memory_bytes: 25608
#include <iostream>
#include <stdio.h>
#include<algorithm>
#include <math.h>
#include <string.h>
#define eps 1e-9
typedef long long int ll;
#define p1 3.1415926535898
using namespace std;
int a;
int main()
{
    int n;
    int k=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a;
        if(a%2==0)
        {
            if(a%3!=0&&a%5!=0)
            {
                k=1;
            }
        }
    }
    if(k==0)
    {
        cout<<"APPROVED"<<endl;
    }
    else
    {
        cout<<"DENIED"<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
using System;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Text;

namespace Fish.aizu
{
	public static class AizuOnlineJudge
	{
		public static int[] SplitToInts(string line)
		{
			return line.Split(' ').Select(x => int.Parse(x)).ToArray();
		}
		public static double[] SplitToDoubles(string line)
		{
			return line.Split(' ').Select(x => double.Parse(x)).ToArray();
		}
		public static long[] SplitToLongs(string line)
		{
			return line.Split(' ').Select(x => long.Parse(x)).ToArray();
		}
		public static int Main()
		{
			Compute(Console.In, Console.Out);
			return 0;
		}
		public static void Compute(TextReader reader, TextWriter writer)
		{
			string line = null;
			while (null != (line = reader.ReadLine()))
			{
				var values = SplitToInts(line);
				var h = values[0];
				var w = values[1];
				if (0 == h && 0 == w)
				{
					break;
				}
				
				var rowFlag = true;
				var colFlag = true;
				
				for (int hh = 0; hh < h; hh++)
				{
					colFlag = rowFlag;
					for (int ww = 0; ww < w; ww++)
					{
						writer.Write(colFlag ? '#' : '.');
						colFlag = !colFlag;
					}
					rowFlag = !rowFlag;
					writer.WriteLine();
				}
				writer.WriteLine();
			}
		}
	}
}

Measured memory_bytes: 5652
#include <iostream>
#include <algorithm>
#include <vector>

using lint = long long;

int main() {
    int n;
    lint m, v, p;
    std::cin >> n >> m >> v >> p;

    std::vector<lint> as(n);
    for (auto& a : as) {
        std::cin >> a;
    }
    std::sort(as.begin(), as.end());

    int ng = -1, ok = n - p;
    // ok問目は選べる
    while (ok - ng > 1) {
        int mid = (ok + ng) / 2;
        lint goal = as[mid] + m;

        lint sum = 0, overcnt = std::min(v, p) - 1;
        for (int i = 0; i <= n - std::min(v, p); ++i) {
            if (i == mid) continue;

            if (goal < as[i]) {
                ++overcnt;
            } else {
                sum += std::min(m, goal - as[i]);
            }
        }

        if (overcnt >= p || sum < m * (v - p)) {
            ng = mid;
        } else {
            ok = mid;
        }
    }

    std::cout << n - ok << std::endl;
    return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder02
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] z = Console.ReadLine().Split(' ');
            int a = int.Parse(z[0]);
            int b = int.Parse(z[1]);
            int c = int.Parse(z[2]);
            if (b / a >= c)
            {
                Console.WriteLine(c);
            }else if (b / a < c && b/a >=1)
            {
                Console.WriteLine((b-(b%a))/a);
            }
            else Console.WriteLine(0);
        }
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define ll long long
#define lld long long double
#define pb push_back
#define mp make_pair
#define M 1000000007
using namespace std;

ll f(ll n, ll w, ll a[], ll b[]) {
	ll value = 0;
	for (ll i = 0; i < n; i++) value += b[i];
	vector<ll>dp(value + 1, 1e18L + 5);
	dp[0] = 0;
	for (ll i = 0; i < n; i++) {
		for (ll j = value - b[i]; j >= 0; j--) {
			dp[j + b[i]] = min(dp[j + b[i]], dp[j] + a[i]);
		}
	}
	ll ans = 0;
	for (ll i = 0; i <= value; i++) {
		if (dp[i] <= w) {
			ans = max(ans, i);
		}
	}
	return ans;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	ll n, w;
	cin >> n >> w;
	ll a[n], b[n];
	for (ll i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	cout << f(n, w, a, b);
	return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());

            if (a * b == 2)
            {
                Console.WriteLine(3);
            }else if(a*b==3){
                Console.WriteLine(2);
            }
            else
            {
                Console.WriteLine(1);
            }

            //ここまで
        }
    }
}


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

int main(){
  ll n,a,b;
  cin >> n>>a>>b;
  ll ans = n/(a+b)*a;
  ll rem = n%(a+b);
  ans += min(a,rem);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, res;
  cin >> a >> b;
  res = a * b;
  if (res % 2 == 0) {
      cout << "Even" << endl;
  }
  else {
      cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}


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

  int n;
  string s;
  cin>>n>>s;
  int ans=0;
  rep(i,n-2){
    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') ans++;
  }

  cout<<ans<<endl;


}

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

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

    bool flag;
    int ans = 0;

    for(int i=0; i<s.size(); ++i){
        int digit = s[i] - '0';
        ans += digit % 9;
        ans %= 9;
    }

    if(ans %9 == 0){
        flag = true;
    }else{
        flag = false;
    }

    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3752
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_4_B&lang=jp

"""
import sys
from sys import stdin
from math import pi
input = stdin.readline


def main(args):
    r = float(input())
    print('{:.6f} {:.6f}'.format(r**2*pi, 2*pi*r))


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

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

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

int main()
{   
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    int yen;

    if (a + b > 2*c) {

        if (x > y)
        yen = 2*min(x, y)*c + (x-y)*a;

        else
        yen = 2*min(x, y)*c + (y-x)*b;

        yen = min(yen, 2*max(x, y)*c);
    }   
    else 
        yen = a * x + b * y;

    cout << yen << endl;
    
    
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

/**
 *
?????§?????????????????????

??\????????????????????????H cm ?????? W cm ????????§????????????????????¢?????????????????°?????????????????????????????????

#.#.#.#.#.
.#.#.#.#.#
#.#.#.#.#.
.#.#.#.#.#
#.#.#.#.#.
.#.#.#.#.#
?????????????????? 6 cm ?????? 10 cm ???????????¢?????¨??????????????????

????????¢???????????? "#" ??¨????????????????????????????????????

 *
 *
 */
public class Main {

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

	public void run(){

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String inputData;
        List<Square> squareList = new ArrayList<Square>();
        try {
        	//??\???
	        while(true){
				inputData = reader.readLine();
	            if("0 0".equals(inputData)){
	            	break;
	            }else{
					String[] strNumber = inputData.split(" ");
					int h = Integer.parseInt(strNumber[0]);
					int w = Integer.parseInt(strNumber[1]);
					squareList.add(new Square(h,w));
	            }
	        }

	        //??????
	        for(Square square : squareList){
				outputSquare(square.h , square.w);
				System.out.println();
	        }

		} catch (IOException e) {
			e.printStackTrace();
		}

	}

	/**
	 * ????????¢?????????
	 * @param h
	 * @param w
	 */
	private void outputSquare(int h, int w) {
		StringBuilder sbLine0 = new StringBuilder();
		for(int i=0;i < w ;i++){
			if(i%2 == 0){
				sbLine0.append("#");
			}
			else
			{
				sbLine0.append(".");
			}
		}
		StringBuilder sbLine1 = new StringBuilder();
		sbLine1.append(sbLine0.toString().substring(1));
		if(sbLine1.toString().length()%2 == 0){
			sbLine1.append(".");
		}else{
			sbLine1.append("#");
		}

		for(int i=0;i < h;i++){
			if(i%2 == 0){
				System.out.println(sbLine0.toString());
			}else{

				System.out.println(sbLine1.toString());
			}
		}
	}

	/**
	 * ????§???¢?????????
	 * h,w???????????????
	 * ??????Inner??????????????????????????§????????????????????§?????????
	 *   ?????????????????????????????§?????¬????????????????????????????????¨?????????
	 *   AOJ??????Main??????????????????submit???????????????
	 *   ?????????????????£????????§Inner?????????????????????????????????
	 */
	class Square{

		public int h;
		public int w;

		Square(int _h ,int _w){
			h = _h;
			w = _w;
		}
	}


}

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

using namespace std;

int main() {
  vector<pair<int,int> > hw(6);
  for(auto&a:hw) {
    cin >> a.first >> a.second;
    if(a.first<a.second) swap(a.first,a.second);
  }
  sort(hw.rbegin(),hw.rend());
  bool flag=true;
  for(int i=0;i<6;i+=2)
    if(hw[i]!=hw[i+1]) flag=false;
  if(!(hw[0].first==hw[2].first&&hw[0].second==hw[4].first&&
       hw[2].second==hw[4].second)) flag=false;
  cout << (flag?"yes":"no") << endl;
  
  return 0;
}



Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int i,j,a,size,temp,num,count=0;
	cin >> size;
	vector<long long int> arr(size);
	for(i=0;i<size;i++)
		cin >> arr[i];
	for(i=0;i<size-1;i++)
	{
		if(arr[i+1] < arr[i])
		{
			temp = (arr[i] - arr[i+1]);
			arr[i+1] = arr[i];
			count += temp;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 4728
// template version 1.15
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define slice(l, r) substr(l, r-l)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
    #include "lib/dump.hpp"
#else
    #define dump(...) 42
    #define dump_1d(...) 42
    #define dump_2d(...) 42
    #define cerrendl 42
#endif
//}}}

signed main() {
    string s;cin>>s;
    set<int> st;
    rep(i, 3){
        st.insert(s[i]);
    }
    cout << (sz(st)==1 ? "No" : "Yes") << endl;
    
    return 0;
}


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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
template<class T, class S> inline pair<T, S> mp(T x, S y){ return make_pair(x, y); }
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-12;

string s;

int main()
{
  while(getline(cin, s) && s != "."){
    stack<char> st;
    vrep(v, s){
      if(*v == '(' || *v == '[') st.push(*v);
      if(*v == ')' || *v == ']'){
        if(st.empty()){
          st.push('(');
          break;
        }
        if(st.top() == '(' && *v == ')'){ st.pop();  continue; }
        if(st.top() == '[' && *v == ']'){ st.pop();  continue; }
        break;
      }
    }
    puts(st.empty() ? "yes" : "no");
  }

  return 0;
}

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

int	main() {
	long H, W;
	cin >>H >>W;
	long S=H*W;
	long HW=H*W;
	for (long h=1; h+h<=H; h++) {
		long S1=h*W;
		long S2=(H-h)*(W/2);
		long S3=HW-S1-S2;
		long SMax=max(S1, max(S2, S3));
		long SMin=min(S1, min(S2, S3));
		S=min(S, SMax-SMin);
		S2=(H-h)/2*W;
		S3=HW-S1-S2;
		SMax=max(S1, max(S2, S3));
		SMin=min(S1, min(S2, S3));
		S=min(S, SMax-SMin);
	}
	swap(H, W);
	for (long h=1; h+h<=H; h++) {
		long S1=h*W;
		long S2=(H-h)*(W/2);
		long S3=HW-S1-S2;
		long SMax=max(S1, max(S2, S3));
		long SMin=min(S1, min(S2, S3));
		S=min(S, SMax-SMin);
		S2=(H-h)/2*W;
		S3=HW-S1-S2;
		SMax=max(S1, max(S2, S3));
		SMin=min(S1, min(S2, S3));
		S=min(S, SMax-SMin);
	}
	cout <<S <<endl;
	return 0;
};


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

vector<ll> sosu;
void Sosu(ll x){
    bool s[x+1];
    fill(s,s+x+1,true);
    ll i;
    for(i=2;i*i<=x;i=i+2){
        if(s[i]){
            sosu.pb(i);
            for(ll j=2;j*i<=x;j++){
                s[j*i]=false;
            }
        }
        if(i==2)i--;
    }
    for(i=i;i<=x;i=i+2){
        if(s[i]){
            sosu.pb(i);
        }
    }
}

int main(){
    ll n;cin>>n;
    Sosu(55555);
    ll ans[55];
    ll c=0;
    rep(i,0,sosu.size()-1){
        if(sosu[i]%5==1){
            ans[c]=sosu[i];
            c++;
        }
        if(c==55){
            break;
        }
    }
    cout<<ans[0];
    rep(i,1,n-1){
        cout<<' '<<ans[i];
    }
    cout<<endl;
    
    return 0;
}


Measured memory_bytes: 384
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

//const long long int MOD = 1000000007;
const int MOD = 1000000007;
//const int MOD = 998244353;
//const long long int MOD = 998244353;
const double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

void Calculate_Depth(vector<vector<int>>&edge, vector<int>&depth, int stnode) {
	depth[stnode] = 0;
	queue<int>Q;
	Q.push(stnode);
	while (!Q.empty()) {
		int cn = Q.front();
		Q.pop();
		for (auto i : edge[cn]) {
			if (depth[i] > depth[cn] + 1) {
				depth[i] = depth[cn] + 1;
				Q.push(i);
			}
		}
	}
	return;
}

void Search(vector<vector<int>>&edge, vector<int>&depth, long long int& ans, int node) {
	ans %= MOD;
	int num = K;
	if (!depth[node])num--;
	else num -= 2;
	for (auto i : edge[node]) {
		if (depth[i] > depth[node]) {
			Search(edge, depth, ans, i);
			//cout << node << " " << num << " " << ans << endl;
			ans *= num;
			ans %= MOD;
			num--;
		}
	}
	return;
}

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

	cin >> N >> K;
	if (N == 1) {
		cout << K << endl;
		return 0;
	}
	vector<vector<int>>edge(N);
	for (int i = 1; i < N; i++) {
		cin >> L >> R;
		L--;
		R--;
		edge[L].push_back(R);
		edge[R].push_back(L);
	}
	vector<int>depth(N, MOD);
	Calculate_Depth(edge, depth, 0);
	long long int ans = K;
	Search(edge, depth, ans, 0);
	cout << ans << endl;
}

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

int main() {
    int K,S;
    cin >> K >> S;
    int ans = 0;
    for(int i = 0; i <= K; i++) {
        for(int j = 0; j <= K; j++) {
            if(S-i-j <= K && S-i-j >= 0) {
                ans++;
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
N = int(input())
x = [list(map(int, input().split())) for i in range(N)]
cnt = 0
sum = 0
flag = 0
T = X = Y = 0
for i in range(N):
    cnt = x[i][0] - T
    sum = abs(x[i][1]- X) + abs(x[i][2]- Y)
    T = x[i][0]
    X = x[i][1]
    Y = x[i][2]
    if cnt < sum or cnt % 2 != sum % 2:
        flag = 1
        break
if flag == 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 27380
import java.util.Scanner;

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

		String str = scan.next();
		long k = scan.nextLong();
		char result = 0;
		if (k >= str.length()) {
		} else {
			str = str.substring(0, (int) k );
		}
		for (int i = 0; i <= str.length() - 1; i++) {
			result = str.charAt(i);
			if (result != '1') {
				break;
			}
		}
		System.out.println(result);
	}

}


Measured memory_bytes: 22868
#include <iostream>
#include <cmath>

int mandist(int x, int nx, int y, int ny) {
    return std::abs(x - nx) + std::abs(y - ny);
}

bool solve() {
    int N;  std::cin>>N;
    int x = 0, y = 0, t = 0;
    for (int i = 0; i < N; ++i) {
        int nt, nx, ny;     std::cin>>nt>>nx>>ny;
        int dist = mandist(x, nx, y, ny);
        int dt = nt - t;
        if (dist > dt)
            return false;
        if (dist < dt && (std::abs(dist - dt) & 1))
            return false;
        t = nt;
        x = nx;
        y = ny;
    }
    return true;
}

int main() {
    if (solve())
        std::cout<<"Yes";
    else
        std::cout<<"No";
    
    return 0;
}

Measured memory_bytes: 256
import fractions

def lcm(x, y):
  return (x*y) // fractions.gcd(x, y)

A, B, C, D = map(int,input().split())

A_div_byCorD = (A-1)//C + (A-1)//D - (A-1)//lcm(C, D)
B_div_byCorD = B//C + B//D - B//lcm(C, D)
#print(A_div_byCorD)
#print(B_div_byCorD)
canbedivided = B_div_byCorD - A_div_byCorD

print(B-A+1 - canbedivided)


Measured memory_bytes: 5048
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define len(v) int(v.length())
#define lob(v,n) lower_bound(all(v),n)
#define lobi(v,n) lower_bound(all(v),n) - v.begin()
#define upb(v,n) upper_bound(all(v),n)
#define upbi(v,n) upper_bound(all(v),n) - v.begin()
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    int H,W,K;
    cin >> H >> W >> K;
    ve<ve<char>> grid(H,ve<char>(W));
    
    rep(i,H) rep(j,W) cin >> grid[i][j];
    
    int ans = 0;
    
    rep(h,1<<H){
        rep(w,1<<W){
            bitset<10> a(h);
            bitset<10> b(w);
            
            int an = 0;
            
            rep(i,H){
                if(a[i] == 0) continue;
                rep(j,W) if(b[j]) {if(grid[i][j] == '#') an++;}
            }
            
            if(an == K) ans++;
        }
    }
    
    
    cout << ans << endl;
    
    
    

    return 0;
}


Measured memory_bytes: 3600
using System;
using System.Linq;
class program
{
    static void Main()
    {
        var nmx = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var n = nmx[0];
        var m = nmx[1];
        var x = nmx[2];
        var ca = new int[n][];
        for (int i = 0; i < n; i++)
        {
            ca[i] = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        }
        int itr = 1 << n;
        int ans = 1300000;
        for(int i = 1;i < itr; i++)
        {
            int prime = 0;
            int[] a = new int[m];
            for (int j = 0; j < n; j++)
            {
                if((i >> j & 1) == 1)
                {
                    prime += ca[j][0];
                    for (int k = 1; k <= m; k++)
                    {
                        a[k-1] += ca[j][k];
                    }
                }
            }
            if(a.All(value => value >= x))
            {
                ans = Math.Min(prime, ans);
            }
        }
      Console.Write(ans == 1300000 ? -1 : ans);
    }
}

Measured memory_bytes: 28652
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

int32_t main(){
	IOS;
	int a;
	string s;
	cin >> a >> s;
	int c = (int)((s[0]-'0')*100 + (s[2]-'0')*10 + (s[3]-'0'));
	int res = (a*c)/100;
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var h1 = sc.nextInt();
		var m1 = sc.nextInt();
		var h2 = sc.nextInt();
		var m2 = sc.nextInt();
		var k = sc.nextInt();
		sc.close();

		var result = Math.max((h2 - h1) * 60 + (m2 -m1) - k, 0);
		System.out.println(result);
	}
}


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

int main(){
  int N;
  cin >> N;
  vector<int> d(N), num(110);
  rep(i, N) {
    cin >> d[i];
    num[d[i]]++;
  }
  
  int ans = 0; 
  rep(i, 100){
    if(num[i+1]) ans++; 
  }
  
  cout << ans << endl;

}


Measured memory_bytes: 256
from collections import deque
dq=deque([])
#pop/append/(append,pop)_left/in/len/count/[]/index/rotate()(右へnずらす)
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    if i%2:
        dq.append(a[i])
    else:
        dq.appendleft(a[i])
print(*list(dq)[::(-1)**(n%2+1)],sep= " ")

Measured memory_bytes: 25412
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;

struct Edge {
    int to, l;
};

int n;
vector<int> ans;
vector<vector<Edge>> g;

void dfs(int v, int p=-1) {
    rep(i,g[v].size()) {
        int u = g[v][i].to;
        int w = g[v][i].l;
        if (u == p) continue;
        if (ans[u] != INF) continue;
        if (w%2) ans[u] = ans[v]^1;
        else ans[u] = ans[v];
        dfs(u,v);
    }
}

int main() {
    //int n;
    cin >> n;
    //vector<vector<Edge>> g(n);
    g.resize(n);
    rep(i,n-1) {
        int u, v, w;
        cin >> u >> v >> w;
        u--; v--;
        g[u].push_back((Edge){v, w});
        g[v].push_back((Edge){u, w});
    }
    ans = vector<int>(n, INF);
    ans[0] = 0;
    dfs(0);
    rep(i,n) cout << ans[i] << endl;
    return 0;
}

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

inline int read()
{
	int x=0,f=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=x*10+c-'0';c=getchar();}
	return x*f;
}
const int maxn = 105;
int n, a[maxn], t[maxn], ans[maxn];
int main()
{
	n = read();
	for (int i = 1; i <= n; i ++) a[i] = read();
	for (int i = 1; i <= n; i ++)
	{
		int pre = i - 1;
		if (a[i] > i) return puts("-1"), 0;
		int now = a[i];
		for (int j = 1; j < i; j ++)
			if (t[j] >= now) ++ t[j];
		t[i] = now;
	}
	for (int i = 1; i <= n; i ++)
		ans[t[i]] = a[i];
	for (int i = 1; i <= n; i ++)
		printf("%d\n", ans[i]);
	return 0;
}

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


using namespace std;

const int INF = (int) 1e5 + 1;
const int MAX_V = (int) 100;

struct edge { int to, cap, cost, rev; };

vector<edge> G[MAX_V];
int dist[MAX_V];
int prevv[MAX_V], preve[MAX_V];

void add_edge(int from, int to, int cap, int cost) {
    G[from].push_back( (edge) { to, cap, cost, (int) G[to].size() });
    G[to].push_back( (edge) { from, 0, -cost, (int) G[from].size() - 1});
}

int dfs(int v, int t, int f) {
    if (v == t) return f;
    dist[v] = true;
    for (auto &e: G[v]) {
        if (!dist[e.to] && e.cap > 0) {
            int d = dfs(e.to, t, min(f, e.cap));
            if (d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

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

    int V, E, f;
    cin >> V >> E >> f;

    for (int i = 0; i < E; ++i) {
        int u, v, c, d;
        cin >> u >> v >> c >> d;
        add_edge(u, v, c, d);
    }

    int s = 0;
    int t = V -1;
    int res = 0;
    while (f > 0) {
        fill(dist, dist + V, INF);
        dist[s] = 0;
        bool update = true;
        while (update) {
            update = false;
            for (int v = 0; v < V; ++v) {
                if (dist[v] == INF) continue;
                for (int i = 0; i < G[v].size(); ++i) {
                    edge &e = G[v][i];
                    if (e.cap > 0 && dist[e.to] > dist[v] + e.cost) {
                        dist[e.to] = dist[v] + e.cost;
                        prevv[e.to] = v;
                        preve[e.to] = i;
                        update = true;
                    }
                }
            }
        }
        if (dist[t] == INF) {
            res = -1;
            break;
        }
        
        int d = f;
        for (int v = t; v != s; v = prevv[v]) {
            d = min(d, G[prevv[v]][preve[v]].cap);    
        }
        f -= d;
        res += d * dist[t];
        for (int v = t; v != s; v = prevv[v]) {
            edge &e = G[prevv[v]][preve[v]];
            e.cap -= d;
            G[v][e.rev].cap += d;
        }
    }

    cout << res << '\n';

    return 0;
}



Measured memory_bytes: 3220
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
#define mod 1000000007
using namespace std;
ll dp[62][4][4];
ll n;
char a[2][62];
ll func(ll here, ll xx, ll yy) {
	if (here ==n)return 1;
	ll &ret = dp[here][xx][yy];
	if (ret != -1)return ret;
	ret = 0;
	if (a[0][here] == a[1][here]) {
		for (int i = 1; i <= 3; i++) {
			if (i != xx&&i != yy)
				ret += func(here + 1, i, i);
		}
	}
	else {
		for (int i = 1; i <= 3; i++) {
			for (int y = 1; y <= 3; y++) {
				if (i == y)continue;
				if (i != xx&&y != yy)
					ret += func(here + 2, i, y);
			}
		}
	}
	ret %= mod;
	return ret;
}
int main()
{
	memset(dp, -1, sizeof(dp));
	scanf("%lld", &n);
	for (int i = 0; i < 2; i++) {
		for (int y = 0; y < n; y++) {
			scanf(" %1c", &a[i][y]);
		}
	}
	printf("%lld\n", func(0, 0, 0));
}

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

int main(){
  int n,x=0;
  cin >>n;
  vector<string> word(n);
  
  for (int i=0;i<n;i++){
    cin >>word.at(i);
  }
  for (int i=0;i<n;i++){
    for (int j=0;j<i;j++){
       if (word.at(i)==word.at(j)){
         cout << "No" <<endl;
         x++;
         break;
       }
    }
  }
  for (int i=0;i<n-1;i++){
    if (x==0 && word.at(i).at(word.at(i).size()-1)!=word.at(i+1).at(0)){
      cout << "No" <<endl;
      x++;
      break;
    }
  }
  if (x==0){
    cout << "Yes" <<endl;
  }
}

Measured memory_bytes: 256
/*
    Life Before Death, Strength Before Weakness, Journey Before Destination
    ------------------------------------------------------------------------
    You don't become great by trying to be great.
    You become great by wanting to do something,
    and then doing it so hard that you become great in the process.
    */
 
    //#pragma comment(linker, ack:200000000")
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include <bits/stdc++.h>
    using namespace std;
    
    #define TRACE
    
    #ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
      cerr << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
      const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
    #else
    #define trace(...)
    #endif
    
    #define rep(i, n)    for(ll i = 0; i < (n); ++i)
    #define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
    #define repD(i, a, n)  for(ll i = a; i >= (n); --i)
    #define trav(a, x) for(auto& a : x)
    #define all(x) x.begin(), x.end()
    #define sz(x) (int)(x).size()
    #define fill(a)  memset(a, 0, sizeof (a))
    #define fst first
    #define snd second
    //#define mp make_pair
    #define pb push_back
    #define PI           3.141592653589793238462643383279502884197169399  /* pi */
    // #define te    
    typedef long double ld;
    typedef long long ll;
    typedef pair<ll, ll> pii;
    typedef vector<ll> vi;
    const int maxN = 100100;

    void solve() {
        ll n;
        cin >> n;
        ll a[n], b[n], c[n], sum =0;
        rep(i, n) cin >> a[i];
        rep(i, n) cin >> b[i];
        rep(i, n-1) cin >> c[i];
        rep(i, n-1) {
            sum+=b[a[i]-1];
            if(a[i] + 1 == a[i+1]) sum+=c[a[i]-1];
            //cout <<b[a[i]-1] << " " <<c[a[i]-1]<< endl;
        }sum+=b[a[n-1]-1];
        cout << sum << endl;
    }
 
    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
      // ll ti;   cin >> ti;  while(ti--)
      solve();
      return 0;
    } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;


void Main(){

  ll N,M; cin>>N>>M;

  ll ans=0;

  if(N==1 and M==1) ans=1;
  else if(N==1) ans=M-2;
  else if(M==1) ans=N-2;
  else ans=(N-2)*(M-2);

  cout<<ans<<"\n";
}

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


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

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ALL(a) begin(a), end(a)
#define SZ(a) ((int)(a).size())

#define REP(a, b) for (int a = 0; a < (b); a++)
#define FOR(a, b, c) for (int a = (b); a <= (c); a++)
#define REPD(a, b) for (int a = (b) - 1; a >= 0; a--)
#define FORD(a, b, c) for (int a = (b); a >= (c); a--)

#define MIN(a, b) (a) = min((a), (b))
#define MAX(a, b) (a) = max((a), (b))

#ifdef __DEBUG
#define debug if (true)
#else
#define debug if (false)
#endif

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

template <typename T> using V = vector<T>;
template <typename T> using VV = vector<V<T>>;
template <typename T> using VVV = vector<VV<T>>;

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2> &p) {
  return is >> p.fi >> p.se;
}

const int N = 1e5 + 5;

int n, m;
int memo[N];
vector<int> g[N];

int go(int u) {
  if (memo[u] != -1) return memo[u];
  int ret = 0;
  for (int v : g[u]) MAX(ret, go(v) + 1);
  return memo[u] = ret;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> m;
  REP(i, m) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    g[x].pb(y);
  }
  memset(memo, -1, sizeof(memo));
  REP(i, n) go(i);
  cout << *max_element(ALL(memo)) << endl;
}


Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    int ans[N];
    for(int i = 0; i< N;i++){
        cin >> ans[i];
      	cout << ans[i];
      	if(i!= N-1){
          cout << " ";
        }
    }
  	cout << endl;
    for(int i = 1; i < N;i++){
        int a = ans[i];
        int j = i-1;
        while(j >= 0 && ans[j]>a){
            ans[j+1] = ans[j];
            j--;
        }
        ans[j+1] = a;
        for(int k = 0; k <N;k++){
            cout << ans[k];
            if(k!= N-1){
                cout << " ";
            }
        }
        cout << endl;
    }
}


Measured memory_bytes: 3096