akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

const int MAX = 105;
const int N = 1e5 + 5;
int dp[N];
int arr[MAX], n;

bool solve(int k)
{
	if(!k) return 0;
	if(dp[k] != -1) return dp[k];
	dp[k] = 0;
	for(int i = 0; i < n; i++) {
		if(k >= arr[i])
		dp[k] |= !solve(k - arr[i]);
	}
	return dp[k];
}
int main()
{
	boost;
	int k, i;
	cin >> n >> k;
	fo(i, 0, n)
	cin >> arr[i];
	memset(dp, -1, sizeof dp);
	cout << (solve(k) ? "First" : "Second");
}


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

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int a, b;
    scan(a, b);

    int h = 100, w = 100;
    auto ban = new char[][](h, w);
    foreach (i ; 0 .. h) {
        foreach (j ; 0 .. w) {
            if (i < h / 2) {
                ban[i][j] = '#';
            }
            else {
                ban[i][j] = '.';
            }
        }
    }

    a--, b--;

    for (int i = 0; i < 50; i += 2) {
        if (a == 0) break;
        for (int j = 0; j < 100; j += 2) {
            if (a == 0) break;
            ban[i][j] = '.';
            a--;
        }
    }

    for (int i = 51; i < 100; i += 2) {
        if (b == 0) break;
        for (int j = 0; j < 100; j += 2) {
            if (b == 0) break;
            ban[i][j] = '#';
            b--;
        }
    }

    writeln(h, " ", w);
    writefln("%-(%s\n%)", ban);
}










void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,R;
    cin >>N>>R;
    ll ans;
    if(N>=10){
        ans = R;
    }else{
        ans = R+100*(10-N);
    }
    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 3548
#include<iostream>
#include<string>
#include<cmath>
//#include<array>
#include<algorithm>
//#include<deque>
#include<vector>
//#include<utility>
#include<set>
//#include<map>
//#include<list>

using namespace std;
using LLI = long long int;
vector<int>dir_x = {0,0,1,1,1,-1,-1,-1};
vector<int>dir_y = {1,-1,1,0,-1,1,0,-1};
vector<int>dir_x2 = {0,0,1,-1};
vector<int>dir_y2 = {1,-1,0,0};

//class UnionFind {
//public:
//	vector<int>data;
//	UnionFind(int size) :data(size, -1) {};
//	bool unionset(int x, int y) {
//		x = root(x), y = root(y);
//		if (x != y) {
//			if (data[y] < data[x]) {
//				swap(x, y);
//			}
//			data[x] += data[y];
//			data[y] = x;
//		}
//		return x != y;
//	}
//	bool findset(int x, int y) {
//		return root(x) == root(y);
//	}
//	int root(int x) {
//		return data[x] < 0 ? x : data[x] = root(data[x]);
//	}
//	int size(int x) {
//		return -data[root(x)];
//	}
//};

//int gcd(int x, int y) {
//	int tmp, r;
//	if (x < y) {
//		tmp = x;
//		x = y;
//		y = tmp;
//	}
//	r = x % y;
//	while (r != 0) {
//		x = y;
//		y = r;
//		r = x % y;
//	}
//	return y;
//}

//vector<vector<int>>sub;
//int dfs(int id) {
//	if (sub[id].size() == 0) {
//		return 1;
//	}
//	int minP = (int)1e9;
//	int maxP = 0;
//	for (int i : sub[id]) {
//		int P = dfs(i);
//		minP = min(minP, P);
//		maxP = max(maxP, P);
//	}
//	return minP + maxP + 1;
//}

//const int n_max = 8;
//array<array<bool, n_max>, n_max>graph;
//int dfs(int v,int N,array<bool,n_max>visited) {
//	int ret = 0;
//	bool all_visited = true;
//	for (int i = 0; i < N;i++) {
//		if (visited[i] == false) {
//			all_visited = false;
//		}
//	}	
//	if (all_visited) {
//		return 1;
//	}
//	for (int i = 0; i < N;i++) {
//		if (graph[v][i] == false) {
//			continue;
//		}
//		if (visited[i] == true) {
//			continue;
//		}
//		visited[i] = true;
//		ret += dfs(i,N,visited);
//		visited[i] = false;
//	}
//	return ret;
//}

//long nCr(int n,int r) {
//	long ans = 1;
//	for (int i = n; i > n - r;i--) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1;i++) {
//		ans = ans / i;
//	}
//	return ans;
//}

int main(void) {
	int N,a,res = 0;
	cin >> N;
	for (int i = 0; i < N;i++) {
		cin >> a;
		res += a;
	}
	res -= N;
	cout << res << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
char map[20][20];
int ans = 0;

void dps(int x, int y);

int main(void){
	while(scanf("%s", map[0]) != EOF){
		ans = 0;
		for(int i=1; i<12; i++){
			scanf("%s", map[i]);
		}

		for(int i=0; i<12; i++){

			for(int j=0; j<12; j++){
				if(map[i][j] == '1'){
					map[i][j] = '3';
					ans++;
					if(j+1 < 12) dps(i, j+1);
					if(j-1 >= 0) dps(i, j-1);
					if(i+1 < 12) dps(i+1, j);
					if(i-1 >= 0) dps(i-1, j);
				}
			}
		}

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

	return 0;
}

void dps(int y, int x){
	if(map[y][x] == '1'){
		map[y][x] = '0';
		if(x+1 < 12) dps(y, x+1);
		if(x-1 >= 0) dps(y, x-1);
		if(y+1 < 12) dps(y+1, x);
		if(y-1 >= 0) dps(y-1, x);
	}
}

Measured memory_bytes: 0
X, Y = map(int, input().split())
rewords = [300000, 200000, 100000]
ans = 0
if X <= 3:
    ans += rewords[X-1]
if Y <= 3:
    ans += rewords[Y-1]
if X == 1 and Y == 1:
    ans += 400000

print(ans)


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

int L, N;
string s;
vector<string> S;

int main () {
  cin >> N >> L;
  for (int i = 0; i < N; i++) {
    cin >> s;
    S.push_back(s);
  }
  sort(S.begin(), S.end());
  for (int i = 0; i < N; i++) cout << S.at(i);
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  map<char,int> M;
  int N; cin>>N;
  rep(i,0,N){
    string S; cin>>S;
    M[S[0]]++;
  }
  int ans=0;
  vector<char> C={'M','A','R','C','H'};
  rep(i,0,(1ll<<5)){
    bitset<5> B(i);
    if(B.count()==3){
      int sum=1;
      rep(j,0,5){
        if(B.test(j)) sum*=M[C[j]];
      }
      ans+=sum;
    }
  }
  cout<<ans<<endl;
  }


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private void solve(InputStreamScanner in, PrintWriter out) {
        int n = in.nextInt();
        int k = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }

        int[] dp = new int[n];
        Arrays.fill(dp, 1, n, Integer.MAX_VALUE);

        for (int i = 1; i < n; i++) {
            for (int j = 1; j <= Math.min(i, k); j++) {
                dp[i] = Math.min(dp[i], dp[i - j] + Math.abs(a[i - j] - a[i]));
            }
        }

        out.println(dp[n - 1]);
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
}


Measured memory_bytes: 36656
from collections import deque

def out(time, parking):
  x = len(parking)
  outs = []
  for i in range(x):
    for j in range(2):
      if parking[i][j] != None:
        parking[i][j][0] -= time
  
  for i in range(x):
    c1 = parking[i][0]
    c2 = parking[i][1]
    if c1 != None and c2 != None:
      if c1[0] <= 0 and c2[0] <= 0:
        outs.append([c2[1], c1[1]])
        parking[i][0] = None
        parking[i][1] = None
      elif c2[0] <= 0:
        outs.append([c2[1]])
        parking[i][1] = None
    elif c1 != None:
      if c1[0] <= 0:
        outs.append([c1[1]])
        parking[i][0] = None
    elif c2 != None:
      if c2[0] <= 0:
        outs.append([c2[1]])
        parking[i][1] = None
  lst = []
  for l in outs:
    lst += l
  return lst

def into(num, time, parking):
  x = len(parking)
  times = []
  for i in range(x):
    if parking[i] == [None, None]:
      parking[i][0] = [time, num]
      return
    if parking[i][0] == None:
      times.append((parking[i][1][0], i))
    elif parking[i][1] == None:
      times.append((parking[i][0][0], i))
  times.sort()
  
  for t, ind in times:
    if t >= time:
      if parking[ind][0] == None:
        parking[ind][0] = [time, num]
      else:
        parking[ind][1] = [time, num]
      return
  else:
    max_t = t

  for t, ind in times:
    if t == max_t:
      if parking[ind][0] == None:
        parking[ind][0] = [time, num]
      else:
        parking[ind][1] = [time, num]
      return
 
while True:
  m, n = map(int, input().split())
  if m == 0:
    break
  
  parking = [[None] * 2 for _ in range(m)]
  wait = deque()
  space = m * 2
  ans = []
  
  for t in range(120 * n):
    o = out(1, parking)
    if o:
      space += len(o)
      ans += o

    if t % 10 == 0 and t <= 10 * (n - 1):
      time = int(input())
      wait.append((t // 10 + 1, time))

    for i in range(min(space, len(wait))):
      num, time = wait.popleft()
      into(num, time, parking)
      space -= 1
  print(*ans)


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

using namespace std;

const int MAX = 510000;
const int MOD = 998244353;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    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;
    }
}

long long COM(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;
}


long long int modpow(long long int x,long long int n,long long int mod){
    long long int res = 1;
    while(n>0){
        if(n&1){
            res = (res*x)%mod;
        }
        x = (x*x)%mod;
        n >>= 1;
    }
    return res;
}


int main(){
    long long int N,M,K,ans=0;
    cin >> N >> M >> K;

    COMinit();

    for(int i=0;i<=K;i++){
        long long int add=M;
        add *= modpow(M-1,N-1-i,998244353);
        add %= 998244353;
        add *= COM(N-1,i);
        add %= 998244353;
        ans += add;
        ans %= 998244353;
    }

    cout << ans << endl;
}

Measured memory_bytes: 15588
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()

typedef long long ll;
typedef vector<ll> vi;

const int MOD = 1000003;
const int MAX_N = 1000005;


vi fac(MAX_N); //n!(mod M)
vi ifac(MAX_N); //k!^{M-2} (mod M)
vi inv(MAX_N);

ll mpow(ll x, ll n) {
    ll ans = 1;
    while (n != 0){
        if (n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b) {
    if (a==0 && b==0) return 1;
    if (a<b || a<0) return 0;
    ll tmp = ifac[a-b] * ifac[b] % MOD;
    return tmp * fac[a] % MOD;
}

ll perm(ll a, ll b){
    if(a < b) return 0;
    ll tmp = ifac[a-b] % MOD;
    return tmp * fac[a] % MOD;
}

void init() {
  fac[0] = 1; ifac[0] = 1; inv[0] = 1;
  for (ll i = 0; i<MAX_N; i++){
      fac[i+1] = fac[i] * (i+1) % MOD;
      inv[i+1] = mpow(i+1, MOD-2);
      ifac[i+1] = ifac[i] * inv[i+1] % MOD;
  }
}

ll calc(ll x, ll d, ll n) {
  if (d == 0) {
    return mpow(x, n);
  }
  if (x == 0) {
    return 0;
  }
  ll rec = perm(((MOD-x)*inv[d])%MOD, n) * mpow(MOD-d, n);
  return rec % MOD;
}

int main() {
  int q; cin >> q;
  init();
  rep(i, q) {
    ll x, d, n;
    cin >> x >> d >> n;
    cout << calc(x, d, n) << endl;
  }
  return 0;
}


Measured memory_bytes: 24320
#include <stdio.h>

int main()
{
  int x,y,tmp,r;
  scanf("%d%d",&x,&y);
  if(x<y)
    {
      tmp = x;
      x = y;
      y = tmp;
    }
    while(y>0){
      r=x%y;
      x=y;
      y=r;
    }
    printf("%d\n",x);
    return 0;
}
    



Measured memory_bytes: 2144
#include <stdio.h>

int main(void) {
	long int a,b; scanf("%ld%ld",&a,&b);
	long int temp = a+b;
	if (temp % 2 == 0) {
		printf("%ld", temp/2);
	} else {
		printf("IMPOSSIBLE");
	}
	
	return 0;
}


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

int64_t gcd(int64_t p,int64_t q){
	if(p%q==0)return q;
	return gcd(q,p%q);
}

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,x; cin>>n>>x;
	vector<int>a(n); for(auto&i:a)cin>>i;
	int ans=abs(a.at(0)-x);
	for(auto&i:a){
		ans=gcd(ans,abs(i-x));
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 640
using System;

namespace AtCorder100_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string INPUT=Console.ReadLine();
            string[] INPUT_ = INPUT.Split(' ');
            int A = int.Parse(INPUT_[0]);
            int B = int.Parse(INPUT_[1]);
            if (A > 8 || B > 8) Console.WriteLine(":(");
            if (A <= 8 && B <= 8) Console.WriteLine("Yay!");
        }
    }
}


Measured memory_bytes: 13140
//
//  main.c
//  aojdice2
//
//  Created by 15mac-08 on 2017/05/18.
//  Copyright ?? 2017??´ 15mac-08. All rights reserved.
//

#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    int dice[24][6] = {{2 ,6 ,3 ,4 ,1 ,5},
        {6 ,5 ,3 ,4 ,2 ,1},
        {5 ,1 ,3 ,4 ,6 ,2},
        {4 ,1 ,5 ,2 ,6 ,3},
        {6 ,4 ,5 ,2 ,3 ,1},
        {3 ,6 ,5 ,2 ,1 ,4},
        {1 ,3 ,5 ,2 ,4 ,6},
        {5 ,3 ,6 ,1 ,4 ,2},
        {3 ,2 ,6 ,1 ,5 ,4},
        {2 ,4 ,6 ,1 ,3 ,5},
        {4 ,5 ,6 ,1 ,2 ,3},
        {1 ,5 ,4 ,3 ,2 ,6},
        {2 ,1 ,4 ,3 ,6 ,5},
        {6 ,2 ,4 ,3 ,5 ,1},
        {5 ,6 ,4 ,3 ,1 ,2},
        {4 ,6 ,2 ,5 ,1 ,3},
        {6 ,3 ,2 ,5 ,4 ,1},
        {3 ,1 ,2 ,5 ,6 ,4},
        {1 ,4 ,2 ,5 ,3 ,6},
        {5 ,4 ,1 ,6 ,3 ,2},
        {3 ,5 ,1 ,6 ,2 ,4},
        {2 ,3 ,1 ,6 ,4 ,5},
        {4 ,2 ,1 ,6 ,5 ,3},
        {1 ,2 ,3 ,4 ,5 ,6}};
    
    int i,j,k,l,count=0,num[100][6]={0},n;
    
    scanf("%d",&n);
    
    for (i = 0; i < n; i++) {
        for (j = 0; j < 6; j++) {
            scanf("%d",&num[i][j]);
        }
    }
    
    
    for (i = 0; i < n-1; i++) {
        for (j = i+1; j < n; j++) {
            
            for (k = 0; k < 24; k++) {
                for (l = 0; l < 6; l++) {
                    
                    if (num[i][l] != num[j][dice[k][l]-1]) {
                        break;
                    }
                    count++;
                }
                
                if (count == 6) {
                    printf("No\n");
                    return 0;
                }
                
                count = 0;

            }
        }
    }
    
    printf("Yes\n");
    
    
    return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    ll n, k;
    cin >> n >> k;
    ll m = n % k;
    cout << min(m, abs(m - k)) << endl; 
    return 0;
}


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

ll gcd(int a,int b){
	if(b==0){
		return a;
	}
	if(a%b==0){
		return b;
	}
	gcd(b,a%b);
}
int main() {
	ll n,a[100010],L[100010],R[100010],ans=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	L[0]=0;
	L[1]=a[0];
	for(int i=2;i<n;i++){
		L[i]=gcd( max(L[i-1],a[i-1]), min(L[i-1],a[i-1]));
	}
	R[0]=0;
	R[1]=a[n-1];
	for(int i=2;i<n;i++){
		R[i]=gcd( max(R[i-1],a[n-i]),min(R[i-1],a[n-i]));
	}
	for(int i=0;i<n;i++){
		ll GCD=gcd(max(L[i],R[n-1-i]),min(L[i],R[n-1-i]));
		ans= max(ans,GCD);
	}
	cout << ans;
}

Measured memory_bytes: 2560
#include <stdio.h>

int main(void){

	int a, b;
	int d, r;
	double f;

	scanf("%d %d", &a, &b);

	d = a / b;
	r = a%b;
	f =(double) a /(double) b;

	printf("%d %d %lf", d, r, f);

	return 0;
}

Measured memory_bytes: 636
class Class01
    {
        public static void Main(string[] args)
        {
            for (int i=1;i < 10;i++)
            {
                for (int j = 1; j < 10; j++)
                {
                    System.Console.WriteLine(i + "x" + j +"=" + i * j);
                }
            }
        }
    }

Measured memory_bytes: 9076
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


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

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<int, int> P;
ll ma = 1000000000 + 7;
ll h, w, n,k; string s;
char maze[60][60];
int dis[101][101];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll dp[100010][2]; int x[509][509]; int c[509][509];
int gcd(int x, int y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);

}
int main() {
	cin >> h >> w;
	vector<string> pp(h);
	rep(i, h) {
		cin >> pp[i];
	}
	for (int i = 1; i <= w + 2; i++) {
		if (i == w + 2) {
			cout << '#' << endl;
		}
		else {
			cout << '#';
		}
	}
	for (int i = 0; i < h; i++) {
		cout << '#' << pp[i] << '#' << endl;
	}
	for (int i = 1; i <= w + 2; i++) {
		if (i == w + 2) {
			cout << '#' << endl;
		}
		else {
			cout << '#';
		}
	}
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int m = 0;
		int f = 0;
		int r = 0;

		while (true) {
			m = sc.nextInt();
			f = sc.nextInt();
			r = sc.nextInt();
			int end = m + f + r;
			if (end == -3) {
				break;
			}
			if (m == -1 || f == -1 || m + f < 30) {
				System.out.println("F");
			} else if (m + f >= 80) {
				System.out.println("A");
			} else if (m + f >= 65) {
				System.out.println("B");
			} else if ((m + f >= 50) || (m + f >= 30 && r >= 50)) {
				System.out.println("C");
			} else {
				System.out.println("D");
			}

		}

	}

}

Measured memory_bytes: 26288
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>

using namespace std;

int main()
{
    int H, W, K;
    cin >> H >> W >> K;
    int size = H * W;
    char* c = new char[size];
    for (int i = 0; i < H; ++i) {
        auto base = i * W;
        for (int j = 0; j < W; ++j) {
            cin >> c[base + j];
        }
    }
    int res = 0;
    for (int i = 0, li = ~(0xFFFFFFFF << H); i <= li; ++i) {
        for (int j = 0, lj = ~(0xFFFFFFFF << W); j <= lj; ++j) {
            bool* b = new bool[size];
            for (int s = 0; s < size; ++s) {
                b[s] = (c[s] == '#');
            }
            for (int row = 0; row < H; ++row) {
                if (i & (1 << row)) {
                    auto base = row * W;
                    for (int col = 0; col < W; ++col) {
                        b[base + col] = false;
                    }
                }
            }
            for (int col = 0; col < W; ++col) {
                if (j & (1 << col)) {
                    for (int row = 0; row < H; ++row) {
                        b[row * W + col] = false;
                    }
                }
            }
            int count = 0;
            for (int s = 0; s < size; ++s) {
                if (b[s]) ++count;
            }
            if (count == K) ++res;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3836
#include<stdio.h>
int main(void)
{
  int i,n,k,h,x;
  scanf("%d%d",&n,&k);
  x=0;
  for (i=0;i<n;i++){
      scanf("%d",&h);
      if (h>=k)
        x++;
  }
  printf("%d\n",x);
  return 0;
}


Measured memory_bytes: 128
N, K = map(int, input().split())
h = list(map(int, input().split()))

INF = 10 ** 12
dp = [INF] * 100010

dp[0] = 0

for i in range(1, N):
    for j in range(1, K+1):
        if i - j >= 0:
            dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]))

print(dp[N-1])

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

    double bans = 0;
    for(int i = 0;i < n;i++){
        bans += 1 / a[i];
    }

    cout << setprecision(20)<<1 / bans;

    return 0;
}

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

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	int N;
	cin>>N;
    typedef pair<int,int> P;
    vector<P> pv;
    rep(i,N){
        int a,b;
        cin>>a>>b;
        pv.push_back(P{a,b});
    }

    sort(pv.begin(),pv.end(),[](P p1,P p2){return p1.second<p2.second;});
	
    int t = 0;
    string ans = "Yes";
    for(P p:pv){
        t+=p.first;
        if(t>p.second){
            ans = "No";
            break;
        }
    }
    cout<<ans<<"\n";
    
	return 0;
}

Measured memory_bytes: 2548
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    n, a, b = [int(x) for x in input().split()]
    print(max(0, ((n-1) * b + a) - ((n-1) * a + b) + 1))

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""



"""


Measured memory_bytes: 9404
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  vector<int> copy(N);
  for(int i=0; i<N; i++){
    copy.at(i) = vec.at(i);
  }
  sort(copy.begin(),copy.end());
  map<int,int> mp;
  for(int i=0; i<N; i++){
    mp[copy.at(i)] = i;
  }
  vector<bool> change(N);
  for(int i=0; i<N; i++){
    if(i %2 == mp[vec.at(i)] %2){
      change.at(i) = true;
    }
    else{
      change.at(i) = false;
    }
  }
  int ans = 0;
  for(int i=0; i<N-1; i++){
    if(!change.at(i)){
      if(!change.at(i+1)){
        change.at(i) = true;
        change.at(i+1) = true;  
        ans++;
      }
      else{
        swap(change.at(i),change.at(i+1));
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 7808
//Collecting Balls

#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
using ll = long long;
#define range(a) (a).begin(),(a).end()


int main (){
    int N, K, Ans=0;
    cin >> N >> K;
    vector<int> x(N);
    rep(i,0,N)cin >> x[i];
    rep(i,0,N){
        if(K-x[i]>x[i])Ans+=x[i];
        else Ans+=K-x[i];
    }
    cout << Ans*2 << endl;
    return 0;
}

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

bool cmp(pair<long long, long long> a, pair<long long, long long> b) {
        if(a.second != b.second)
                return a.second > b.second;
        return a.first > b.first;
}

int main(void)
{
	ios_base::sync_with_stdio(0);
	int n, m;
        cin >> n >> m;
        vector<long long> a(n);
	vector<pair<long long, long long> > b(m);
        for(int i = 0; i < n; i++)
                cin >> a[i];
        for(int i = 0; i < m; i++)
                cin >> b[i].first >> b[i].second;
        sort(a.begin(), a.end());
        sort(b.begin(), b.end(), cmp);
        long long j = 0, ans = 0;
        for(int i = 0; i < m; i++) {
                long long l = upper_bound(a.begin(), a.end(), b[i].second) - a.begin();
                if(l > j) {
                        long long en = min(l, j + b[i].first);
                        ans = ans + (en - j) * b[i].second;
                        j = en;
                }
        }
        for(int i = j; i < n; i++)
                ans = ans + a[i];
        cout << ans;
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string A, B;
    cin >> A >> B;
    if (A[0] == B[2] && A[2] == B[0] && A[1] == B[1])
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}

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

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> cnts(n);
  for (int i = 0; i < k; ++i) {
    int d;
    cin >> d;
    for (int j = 0; j < d; ++j) {
      int a;
      cin >> a;
      a--;
      cnts[a]++;
    }
  }

  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (cnts[i] == 0) ans++;
  }
  cout << ans << '\n';
  return 0;
}



Measured memory_bytes: 3636
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define MAXN 200005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> P;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef __gnu_pbds::priority_queue<int,greater<int>,pairing_heap_tag> pq;
int n,m,cnt[MAXN],num[MAXN],a[MAXN];
int ans;
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        cnt[a[i]]++;
    }
    for(int i=1;i<=n;i++)
        for(int j=i;j>=max(1,i+1-cnt[i]);j--) 
            num[j]++;
    for(int i=1;i<=n;i++) if(!num[i]) ans++;
    for(int i=0;i<m;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        int pl=a[x]-cnt[a[x]]+1;
        cnt[a[x]]--;
        if(pl>0) {num[pl]--; if(!num[pl]) ans++;}
        a[x]=y;
        cnt[a[x]]++;
        pl=a[x]-cnt[a[x]]+1;
        if(pl>0) {num[pl]++; if(num[pl]==1) ans--;}
        printf("%d\n",ans);
    }
    return 0;
}



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

int main()
{
	char s[102],t[102];
	int leng=0;
	cin>>s>>t;
	for(leng=0;s[leng]!='\0';leng++);
	for(int i=0;i<leng;i++)
	{
		int equal=1;
		for(int j=0;j<leng;j++)
			if(s[j]!=t[j]){equal=0;break;}
		if(equal==1)
		{
			//cout<<endl<<s[i]<<" "<<t[i];
			cout<<"Yes";return 0;
		}
		char tmp=s[0];
		for(int j=0;j<leng-1;j++)
			s[j]=s[j+1];
		s[leng-1]=tmp;
		//cout<<s<<endl;
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
#ABC70 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7

n = int(input())
g = [[] for _ in range(n)]
for _ in range(n-1):
    a,b,c = map(int,input().split())
    g[a-1].append((b-1,c))
    g[b-1].append((a-1,c))
q,k = map(int,input().split())
que = deque()
que.append(k-1)
dist = [-1]*n
dist[k-1] = 0
while que:
    v = que.popleft()
    for x,c in g[v]:
        if dist[x] == -1:
            dist[x] = dist[v] + c
            que.append(x)

for _ in range(q):
    x,y = map(int,input().split())
    print(dist[x-1] + dist[y-1])


Measured memory_bytes: 82080
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
typedef long long ll;
int main(){
    string S;
    cin >> S;
    bool flag = true;
    REP(i,S.length()-1){
        if(S[i+1] != '9'){
            flag = false;
            break;
        }
    }
    int ans = stoi(S.substr(0,1)) - 1 + 9*(S.length()-1);
    if(flag) ans++;
    cout << ans << endl;
    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;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
//long long ccw(const Point& A, const Point& B, const Point& C) {
//	return 1LL * (B.x - A.x)*(C.y - A.y) - 1LL * (B.y - A.y)*(C.x - A.x);
//}
bool comp(pii x, pii y) {
	if (x.second == y.second) {
		return x.first < y.first;
	}
	return x.second < y.second;
}
pii a[100001];
int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int n, m; cin >> n >> m;
	rep(i, m) {
		cin >> a[i].first >> a[i].second;
	}
	sort(a, a + m, comp);
	int ans = 1;
	int r = a[0].second; 
	for (int i = 1; i < m; i++) {
		if (a[i].first < r) {
			continue;
		}
		else {
			ans += 1;
			r = a[i].second; 
		}
	}

	cout << ans << '\n';



}

Measured memory_bytes: 1024
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl   = input.ReadLine().Split(' ');
        var n     = long.Parse(spl[0]);
        var a     = long.Parse(spl[1]);
        var b     = long.Parse(spl[2]);

        if (a == 0) return 0;

        var c = n / (a + b);
        var m = n % (a + b);

        var r = a * c;
        if (m > 0) {
            r += Math.Min(a, m);
        }

        return r;
    }
}

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

/*
ll cost(vector<ll> h,ll n)
{
	if(n==0)
		return dp[0]=INT_MAX;
	if(n==1)
		return dp[1]=0;
		
	if(dp[n]!=-1)
		return dp[n];
	
	dp[n]=min(cost(h,n-1)+abs(h[n]-h[n-1]),cost(h,n-2)+abs(h[n]-h[n-2]));
	return dp[n];
}
*/
int main(void)
{
	ios_base::sync_with_stdio(false);    
	cin.tie(NULL);
	cout.tie(NULL);
	
	ll n;
	cin>>n;
	
	vector<ll> dp(n);
	vector<ll> h(n);
	
	for(int i=0;i<n;i++)
		cin>>h[i];
		
	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);
	
	for(int i=2;i<n;i++)
	{
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	}
	
	cout<<dp[n-1]<<"\n";
	
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<map>
#include<cmath>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<climits>
#include<string>
#include<sstream>

#define pii pair<int,int>
#define ll long long
#define MOD 1000000007
#define in2d(i,j,H,W)(0<=i&&i<H&&0<=j&&j<W)

using namespace std;
struct UFT{
	vector<int>par;
	int getpar(int i){
		if(par[i]==i)return i;
		return par[i]=getpar(par[i]);
	}
	void unite(int i,int j){
		int t=getpar(i);
		par[t]=getpar(j);
	}
	bool uf(int i,int j){
		return getpar(i)==getpar(j);
	}
	UFT(int n){
		par=vector<int>(n);
		for(int i=0;i<n;i++)par[i]=i;
	}
	~UFT(){
		delete &par;
	}
};
struct SegT{
	vector<ll>container;
	int n;
	void update(int i,ll x){
		int ii=i+n-1;
		container[ii]=x;
		while(ii>0){
			ii=(ii-1)/2;
			//////////////////////////////////////////
			container[ii]=max(container[2*ii+1],container[2*ii+2]);
			//////////////////////////////////////////
		}
	}
	ll get(int l,int r,int l2=0,int r2=-1,int k=0){
		if(r2==-1)r2=n;
		if(r2<=l||r<=l2)return 0;
		if(l<=l2&&r2<=r)return container[k];
		ll vl=get(l,r,l2,(l2+r2)/2,2*k+1);
		ll vr=get(l,r,(l2+r2)/2,r2,2*k+2);
		///////////////////////////
		return max(vl,vr);
		///////////////////////////
	}
	////////////////new///////////////////////
	SegT(vector<int> &A){
		n=pow(2,(int)log2(A.size())+1);
		container=vector<ll>(2*n,0);
		for(int i=0;i<A.size();i++)update(i,A[i]);
	}
	~SegT(){
		delete &container;
	}

};
int main(){
	cout<<fixed<<setprecision(11);
	int N;cin>>N;
	vector<pii >A(N);for(int i=0;i<N;i++){cin>>A[i].first;A[i].second=i;}
	sort(A.begin(),A.end());
	for(int i=0;i<N-1;i++)cout<<A[i].second+1<<" ";
	cout<<A[N-1].second+1<<endl;


	return 0;
}



Measured memory_bytes: 1664
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

s = s()

for i in range(len(s)):
    if (i+1) % 2 !=0:
        if s[i] == "R" or s[i]=="U" or s[i]=="D":
            pass
        else:
            print("No")
            sys.exit()
    else:
        if s[i]=="L" or s[i]=="U" or s[i]=="D":
            pass
        else:
            print("No")
            sys.exit()

print("Yes")


Measured memory_bytes: 10144
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
//typedef pair<long long,long long> P;
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  string s;
  cin>>s;
  int n=s.size();
  int l=0,r=n-1;
  if(n==1){
    cout<<0<<endl;
    return 0;
  }
  if(n==2){
    if(s[0]==s[1]){
      cout<<0<<endl;
    }else if(s[0]=='x' || s[1]=='x'){
      cout<<1<<endl;
    }else{
      cout<<-1<<endl;
    }
    return 0;
  }
  int ans=0;
  //bool flag
  while(r-l>1){
    if(s[l]==s[r]){
      l++;
      r--;
      if(r-l==1){
        if(s[l]==s[r]){
          continue;
        }else if(s[l]=='x' || s[r]=='x'){
          ans++;
          continue;
        }else{
          ans = -1;
          break;
        }
      }
    }else if(s[l]=='x'){
      l++;
      ans++;
      if(r-l==1){
        if(s[l]==s[r]){
          continue;
        }else if(s[l]=='x' || s[r]=='x'){
          ans++;
          continue;
        }else{
          ans = -1;
          break;
        }
      }
    }else if(s[r]=='x'){
      r--;
      ans++;
      if(r-l==1){
        if(s[l]==s[r]){
          continue;
        }else if(s[l]=='x' || s[r]=='x'){
          ans++;
          continue;
        }else{
          ans = -1;
          break;
        }
      }
    }else{
      ans = -1;
      break;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 512
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
#define out(args...){vector<string> a_r_g_s=s_p_l_i_t(#args, ','); e_r_r(a_r_g_s.begin(), args); }
vector<string> s_p_l_i_t(const string& s, char c) { vector<string> v; stringstream ss(s); string x; while(getline(ss,x,c)) v.emplace_back(x); return move(v);}
void e_r_r(vector<string>::iterator it) {}
template<typename T, typename... Args> void e_r_r(vector<string>::iterator it, T a, Args... args){ if(*it==" 1"||*it=="1") cerr<<endl; else cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; e_r_r(++it, args...);}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int n,m;
  cin>>n>>m;
  vector<string> a(n),b(m);
  rep(i,n) cin>>a[i];
  rep(i,m) cin>>b[i];
  rep(i,n-m+1)rep(j,n-m+1){
    int f=1;
    rep(y,m)rep(x,m) if(a[i+y][j+x]!=b[y][x]) f=0;
    if(f){
      //out(i,j,1);
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
  return 0;
}


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

int main(){
  int n;
  int num=0;
  int bottun=1;
  cin>>n;
  vector<int>a(n);
  for(int i=1;i<=n;i++){
    cin>>a[i];
  }
  while(bottun!=2){
    bottun=a[bottun];
    num++;
    if(num>n) break;
  }
  if(num<n) cout<<num<<endl;
  else cout<<-1<<endl;
}
    


Measured memory_bytes: 640
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm> 
#include<climits>
#include<stack>
#include<queue>
#include<set>
#include<cctype>
#include<bitset> 
using namespace std;

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<int,int> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int mod = 1000000007;
const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
}


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

    vector<pair<int,pair<int,int>>> stop(n);

    vector<int> d_time(n);

    REP(i,n){
        int s,t;cin >> s >> t >> stop[i].first;
        stop[i].second.first  = s - stop[i].first;
        stop[i].second.second = t - stop[i].first;        
    }
    sort(all(stop));

    set<pair<int,int> > se;
    REP(i,q) {
        int a;cin>>a;
		se.insert({a,i});
    }
	se.insert({inf,-1});

    vector<ll> ans(q,-1);
    REP(i,n){
        auto itr = se.lower_bound({stop[i].second.first,-1});

		while(itr->first < stop[i].second.second){
			ans[itr->second]=stop[i].first;
			itr=se.erase(itr);
		}
    }

    REP(i,q) pl(ans[i])
	return 0;
}

Measured memory_bytes: 16000
mod = 1000000007
gets
s1 = gets.chomp.split("")
s2 = gets.chomp.split("")

if s1.size == 1 then
  puts 3
  exit
end 

if s1[0] == s2[0] then
  i = 1
  ans = 3
else
  i = 2
  ans = 6
end

while(i < s1.size) do
  if s1[i] == s2[i] then
    if s1[i-1] == s2[i-1] then
      ans = ans * 2
    end
    i += 1
  else
    if s1[i-1] == s2[i-1] then
      ans = ans * 2
    else
      ans = ans * 3      
    end
    i += 2
  end
end    

puts ans % mod



Measured memory_bytes: 1788
//解説AC
//https://www.hamayanhamayan.com/entry/2017/10/15/002234
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

struct UnionFind {
    vector<int> d;//子:親のID(非負) 根:-サイズ(負)
    UnionFind(int n): d(n, -1) {}//全員根→サイズ1に初期化
    int find(int x) {//どのクループか特定
        if (d[x] < 0) return x;//親のID=自分
        return d[x] = find(d[x]);
        //親に対してfindを投げて、親のID取得。
        //代入はメモ化(経路縮約)して計算量を減らしてる。
    }
    bool unite(int x, int y){//UnionFind木を生成
        x = find(x); y = find(y);//根を代入
        if(x == y) return false;//同じならやることがない。falseを返してるのはMSTなどに使うため。
        if(d[x] > d[y]) swap(x, y);
        //サイズの大きい方を小さい方にくっつけるため、xを小さくする。(マイナスに注意)
        d[x] += d[y];//サイズの合算
        d[y] = x;//親を変更
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y);}//同じ集合に属しているか判別
    int size(int x) { return -d[find(x)];}//連結成分サイズを取る
};

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    rep(i, m){
        cin >> a.at(i) >> b.at(i);
        a.at(i)--; b.at(i)--;//0-index
    }
    int ans = 0;
    rep(i, m){
        UnionFind uf(n);//リセット
        rep(j, m){//任意の辺を接続しない
            if(i != j)
            uf.unite(a.at(j), b.at(j));
        }
        int cnt = 0;
        rep(j, n){
            if(uf.find(j) == j) cnt++;//自分自身が親が2人以上=橋
        }
        if(cnt > 1) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256