akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int t,n;
    cin>>t>>n;
    if(!t)return;
    bool map[300][300]={};
    rep(i,n){
        int x,y;
        cin>>x>>y;
        x+=100,y+=100;
        map[x][y]=true;
    }
    int sx,sy;
    cin>>sx>>sy;
    sx+=100,sy+=100;
    queue<pair<pi,int>> q;
    q.push({{sx,sy},t});
    int ans=0;
    int dx[]={1,0,-1,-1,0,1},dy[]={0,-1,-1,0,1,1};
    bool visited[300][300]={};
    while(!q.empty()){
        auto p=q.front();
        q.pop();
        int x=p.fi.fi,y=p.fi.se;
        int l=p.se;
        if(l<0||visited[x][y])continue;
        visited[x][y]=true;
        ans++;
        rep(i,6){
            int nx=x+dx[i],ny=y+dy[i];
            if(!map[nx][ny]){
                q.push({{nx,ny},l-1});
            }
        }
    }
    cout<<ans<<endl;
    run();
}


Measured memory_bytes: 39600
N, X = [int(_) for _ in input().split()]
xs = [int(_) for _ in input().split()]

def gcd(a, b):
    if a < b:
        a, b = b, a
    while b:
        a, b = b, a % b
    return a

xs = [abs(x - X) for x in xs]

result = xs[0]

for x in xs[1:]:
    result = gcd(result, x)

print(result)


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

void solve(long long A, long long B){
    if (A <= 8 && B <= 8) {
        cout << "Yay!" << endl;
    }
    else {
        cout << ":(" << endl;
    }
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		int X=stdIn.nextInt();
		int Y=stdIn.nextInt();
		if(X%Y==0)
			System.out.println(-1);
		else
			System.out.println(X);
	}
}

Measured memory_bytes: 21844
#include <stdio.h>
 
int main (void) {
  int a , b, n;
  scanf("%d %d %d",&n, &a, &b);
  if(a*n>b){
    printf("%d\n",b);
  }else {
    printf("%d\n",a*n);
  } 
  return 0;
}

Measured memory_bytes: 1720
#include <stdio.h>
int main(void){
    int A,B,C;
	scanf("%d %d %d",&A,&B,&C);
  	if((A==B && B==C && A==C)||
       (A!=B && B!=C && A!=C)){
    	printf("No");
    }
  	else{
    	printf("Yes");
    }
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
  ll n;
  cin>>n;
  ll mn = 1000000000;
  rep(i,1,n){
    ll a = i;
    ll b = n-i;
    ll c1 = 0;
    ll c2 = 0;
    for(int j = a; j > 0; j /= 10){
      c1 += j%10;
    }
    for(int j = b; j > 0; j /= 10){
      c2 += j%10;
    }
    mn = min(mn,c1+c2);
  }
  cout << mn << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long int
#define loop(a,n) for(long i=a;i<n;i++)
#define loopr(a,n) for(long i=n-1;i>=a;i--)
#define MOD 10000007
#define mod 1000000007
#define MAX 26
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
using namespace __gnu_pbds;
using namespace std;
#define PI 3.14
double calcAngle(double h, double m)  
{  
    double hour_angle = 0.5 * (h * 60 + m);  
    double minute_angle = 6 * m;  
    double angle = abs(hour_angle - minute_angle);  
    angle = min(360 - angle, angle);  
  
    return angle;  
}  
int main()
{
    fastio;
	#ifndef ONLINE_JUDGE
		freopen("input1.txt  ","r",stdin);
		freopen("output1.txt","w",stdout);
	#endif

    double a,b,h,m;
    cin>>a>>b>>h>>m;
   // double md=m*6;
    //double hd=(30*h)+(m/60)*30;
    double dif=calcAngle(h,m);
    double degs=cos(dif * M_PI / (double)180.0);
    double ans=sqrt((double)(a*a)+(double)(b*b)-(double)(2*a*b*degs));
    cout<<setprecision(20)<<fixed<<ans;
	return 0;
}


Measured memory_bytes: 4164
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
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 = 1LL << 60;

int main(){
    ll n;
    cin >> n;
    double ans;
    if(n%2==0){
        ans = (double)(n / 2) / (double)n;
        cout <<setprecision(10)<< ans << endl;
    }
    else{
        ans = (double)(n/2+1) / (double)n;
        cout <<setprecision(10)<< ans << endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define ll long long int
#define MOD ((int)(1e9) + 7)

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  priority_queue<double> q;
  for(int i=0; i<n; i++) {
    int tp; cin >> tp;
    q.push(-tp);
  }
  while(q.size() != 1) {
    auto o = -q.top();
    q.pop();
    auto t = -q.top();
    q.pop();
    q.push(-(o+t)/2);
  }
  cout << -q.top() << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int solve(int,int);

int n;
int A[21];

int main(){
  int q,i,s;
  int m[201];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    if(A[i]<1 || A[i]>2000){
      exit(1);
    }
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m[i]);
    if(m[i]<1 || m[i]>2000){
      exit(8);
    }
  }

  for(i=0;i<q;i++){
    s=solve(0,m[i]);
    if(s==1){
      printf("yes\n");
    }else if(s==0){
      printf("no\n");
    }
  }

  return 0;
}

int solve(int i,int m){
  int res;

  if(m==0){
    return 1; //true
  }

  if(i>=n){
    return 0; //false
  }

  res=solve(i+1,m) || solve(i+1,m-A[i]);

  return res;
}

Measured memory_bytes: 580
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define INF 1000000000000
#define MOD 1000000007
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3)                                                 \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << endl
#define debug_4(x1, x2, x3, x4)                                             \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5)                                         \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

using namespace std;
using ll = long long;

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    for (int i = k; i < n; i++) {
        if (a[i - k] < a[i])
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 4464
#include <stdio.h>

int main(){
    int a, b;

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

    if((a + b) >= (a - b)){
        if((a + b) >= (a * b)) printf("%d\n", a + b);
        else printf("%d\n", a * b);
    }else{
        if((a - b) >= (a * b)) printf("%d\n", a - b);
        else printf("%d\n", a * b);
    }

    return 0;
}

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

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 = 1LL << 60;
long long dp[100100];

int main() {
    int N, M, C; cin >> N >> M >> C;
    int A[N][M];
    int B[M];
    for(int i = 0; i < M; i++) {
        cin >> B[i];
    }

    int cnt = 0;
    int sum = 0;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < M; j++) {
            cin >> A[i][j];
            sum += A[i][j] * B[j];
        }
        if(sum > -C) cnt++;
        sum = 0;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> xs(m); cin >> xs;
    sort(xs.begin(), xs.end());
    vector<int> ds;
    for(int i = 1; i < m; i++){
        ds.push_back(xs[i] - xs[i - 1]);
    }
    printde(xs, ds);
    sort(ds.begin(), ds.end());
    cout << accumulate(ds.begin(), ds.begin() + max(0, m - n), 0ll) << '\n';
}


Measured memory_bytes: 1276
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
using P=pair<int,int>;
typedef unsigned long long ull;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const ll MOD=1e9+7;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  ll n,k;
  cin >> n >> k;
  ll t=n%k;
  cout << min(t,abs(k-t)) << endl;
}


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

Measured memory_bytes: 3632
N,M = map(int,input().split())
c = 1
if abs(N-M) > 1:
    print(0)
else:
    if N-M == 0:
        for i in range(1,N+1):
            c *= i
            c %= 10**9+7
        c = (2*(c**2))%(10**9+7)
        print(c)
        
    else:
        mina = min(N,M)
        
        for i in range(1,mina+1):
            c *= i
            c %= 10**9+7
        cn = (c*(mina+1))%(10**9+7)
        c = (c*cn)%(10**9+7)
        print(c)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] hw = br.readLine().split(" ");
        int h = Integer.parseInt(hw[0]);
        int w = Integer.parseInt(hw[1]);
        char[][] masu = new char[h+2][w+2];
        
        
        for (int i = 0; i < h; i++) {
            String raw = br.readLine();
            for (int j = 0; j < w; j++) {
                masu[i+1][j+1] = raw.charAt(j);
            }
        }
        
        /*for (int i = 0; i < h; i++) {
            String raw = br.readLine();
            for (int j = 0; j < w; j++) {
                System.out.print(masu[i+1][j+1]);
            }
            System.out.println("");
        }*/
        
        int count = 0;
        for (int i = 1; i <= h; i++) {
            for (int j = 1; j <= w; j++) {
                if (masu[i][j] == '#') {
                    System.out.print('#');
                    continue;
                }
                
                if (masu[i-1][j-1] == '#') count++;
                if (masu[i-1][j] == '#') count++;
                if (masu[i-1][j+1] == '#') count++;
                if (masu[i][j-1] == '#') count++;
                if (masu[i][j+1] == '#') count++;
                if (masu[i+1][j-1] == '#') count++;
                if (masu[i+1][j] == '#') count++;
                if (masu[i+1][j+1] == '#') count++;
                
                System.out.print(count);
                count = 0;
            }
            System.out.print("\n");
        }
    }
}


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

const int maxn = 1e5+5;
int pre[maxn];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    string s; cin >> s;
    int n = s.size();
    for (int i = 1; i <= n; i++) {
        pre[i] = s[i-1] == '1';
        pre[i] += pre[i-1];
    }
    for (int k = n; k >= 1; k--) {
        if (pre[k]-pre[n-k] == 0 || pre[k]-pre[n-k] == 2*k-n) {
            cout << k << '\n';
            return 0;
        }
    }
}



Measured memory_bytes: 848
# abc 154
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

S, T = list(map(str, readline().split()))
A, B = list(map(int, readline().split()))
U = str(readline().strip())

if S == U:
  print(A-1, B)
else:
  print(A, B-1)


Measured memory_bytes: 3064
import sys
from collections import deque

def read():
    return sys.stdin.readline().rstrip()

def main():
    n, m, k = map(int, read().split())
    friend = [[] for _ in range(n)]
    block = [set() for _ in range(n)]
    potential = [set() for _ in range(n)]
    for _ in range(m):
        a, b = [int(i) - 1 for i in read().split()]
        friend[a].append(b)
        friend[b].append(a)
    for _ in range(k):
        c, d = [int(i) - 1 for i in read().split()]
        block[c].add(d)
        block[d].add(c)
    sd = set()
    for u in range(n):
        if u in sd:
            continue
        sn = deque([u])
        pf = set()
        while sn:
            p = sn.pop()
            if p in sd:
                continue
            sd.add(p)
            pf.add(p)
            for f in friend[p]:
                sn.append(f)
        for pfi in pf:
            potential[pfi] = pf
    print(*[len(potential[i]) - len(block[i] & potential[i]) - len(friend[i]) - 1 for i in range(n)])

if __name__ == '__main__':
    main()

Measured memory_bytes: 87408
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;

int read()
{
	int a = 0,x = 1;
	char ch = getchar();
	while(ch > '9' || ch < '0'){
		if(ch == '-') x = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9'){
		a = a*10 + ch-'0';
		ch = getchar();
	}
	return a*x;
}
const int N=1e6+7;
int n,m;
int fa[N];
int find(int s)
{
	if(fa[s] == s) return s;
	return fa[s] = find(fa[s]);
}

int main()
{
	n = read(),m = read();
	for(int i = 1;i <= n;i ++) {
		fa[i] = i;
	}	
	for(int i = 1;i <= m;i ++) {
		int u = read(),v = read();
		if(find(u) != find(v)) {
			fa[find(u)] = v;
		}
	}
	int sum = -1;
	for(int i = 1;i <= n;i ++) 
		if(fa[i] == i) sum ++;
	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 1992
#include <cstdio>
#include <iostream>

using namespace std;

int main() {
	int n;
	scanf("%d", &n);

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

	int L[n];
	L[0] = A[0];
	int length = 1;
	for (int i = 1; i < n; ++i) {
		if (L[length - 1] < A[i]) {
			L[length++] = A[i];
		} else {
// L[j] (j ??? 0 ?????? lengh-1) ????????§ A[i] ??\?????¨??????????????? j ????????? = A[i]
			int left = 0;
			int right = length - 1;
			int mid = (left + right) / 2;

			while (left < right) {
				if (L[mid] >= A[i]) {
					right = mid;
				} else {
					left = mid + 1;
				}
				mid = (left + right) / 2;
			}
			L[mid] = A[i];
		}
	}

	cout << length << endl;

	return 0;
}

Measured memory_bytes: 3840
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
#define MAX_V 1000
int V,cmp[MAX_V];
vector<int> G[MAX_V],rG[MAX_V],vs,a,xx;
int used[MAX_V];
void addedge(int from,int to){
  G[from].push_back(to);
  rG[to].push_back(from);
} 
void dfs(int v){
  used[v]=1;
  for(int i=0;i<G[v].size();i++)
    if(!used[G[v][i]])dfs(G[v][i]);
  vs.push_back(v);
}
void rdfs(int v,int k){
  used[v]=1;
  cmp[v]=k;
  for(int i=0;i<rG[v].size();i++){
    if(!used[rG[v][i]])rdfs(rG[v][i],k);
  }
}
void dfs2(int v,int k){
  used[v]=k;
  for(int i=0;i<G[v].size();i++)
    if(!used[G[v][i]])dfs(G[v][i]);
  xx.push_back(v);
}
int scc(){
  int pp=0;
  memset(used,0,sizeof(used));
  vs.clear();
  for(int v=0;v<V;v++)
    if(!used[v])dfs(v);
  memset(used,0,sizeof(used));
  int k=1;
  for(int i=vs.size()-1;i>=0;i--)
    if(!used[vs[i]]){
      rdfs(vs[i],k++);
    }
  k=1;
  map<int,int>m;
  memset(used,0,sizeof(used));
  for(int i=vs.size()-1;i>=0;i--){
    if(!used[vs[i]]){
      dfs(vs[i]);
      r(j,xx.size())if(used[xx[j]]!=k){
        m[used[xx[j]]]=0;
      }
      m[vs[i]]=cmp[vs[i]];
      k++;
    }
  }
  r(i,V)if(m[i])
    a.push_back(m[i]);
  return k;
}
int main(){
  int x,y;
  while(cin>>V,V){
    double d[V],ans=0;
    a.clear();
    r(i,1000)G[i].clear(),rG[i].clear();
    r(i,V){
      cin>>d[i]>>x;
      r(j,x){
        cin>>y;
        addedge(i,y-1);
      }
    }
    scc();
    int cnt=0;
    r(i,a.size()){
      double p=0;
      int c=0;
      r(j,V)if(cmp[j]==a[i]){
        if(!c++)p+=d[j];
        else p*=d[j];
      }
      if(!cnt++)ans+=(1.0-p);
      else ans*=(1.0-p);
    }
    printf("%.9f\n",ans);
  }
}

Measured memory_bytes: 3388
using System;
using System.Linq;

class Program {
    static void Main(string[] args) {
        var a = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
        var s = new long[4];
        if (a[1] >= a[0]) s[0] = a[1] - a[0];
        if (-a[1] >= a[0]) s[1] = -a[1] - a[0] + 1;
        if (a[1] >= -a[0]) s[2] = a[1] - (-a[0]) + 1;
        if (-a[1] >= (-a[0])) s[3] = -a[1] - (-a[0]) + 2;
        Array.Sort(s); Console.WriteLine(s[2]);
    }
}

Measured memory_bytes: 13652
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

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


int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> a(n+1,0);
  rep(i,n){
    a[i+1] = a[i] + (s[i]=='#'?1:0);
  }
  int ans = inf;
  rep(i,n+1){
    ans = min(ans, a[i]+(n-i-(a[n]-a[i])));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1412
#include <iostream>
using namespace std;
int main()
{
	int h, a, i, count=0;
	cin>>h>>a;
	for(i=0; i<10000000; i++)
	{
		h=h-a;
		count++;
		if (h<=0)
		{
			break;
		}
	}
	cout<<count<<endl;
}


Measured memory_bytes: 256
N,K = map(int,input().split())

P = []

for i in range(N):
    P.append(list(map(int,input().split())))

x = []
y = []
for i in range(N):
    x.append(P[i][0])
    y.append(P[i][1])

x.sort()
y.sort()

num = [[0]*len(y) for i in range(len(x))]
data = [[0]*len(y) for i in range(len(x))]

for i in range(N):
    for j in range(len(x)):
        if P[i][0] == x[j]:
            x0 = j
            break
    for j in range(len(y)):
        if P[i][1] == y[j]:
            y0 = j
            break
    data[x0][y0] += 1

num[0][0] = data[0][0]

for i in range(1,len(x)):
    num[i][0] = num[i-1][0] + data[i][0]

for i in range(1,len(y)):
    num[0][i] = num[0][i-1] + data[0][i]

for i in range(1,len(x)):
    for j in range(1,len(y)):
        num[i][j] = num[i-1][j] + num[i][j-1] - num[i-1][j-1] + data[i][j]

can = []
for i in range(1,len(x)-1):
    for j in range(i+1,len(x)):
        for k in range(1,len(y)-1):
            for l in range(k+1,len(y)):
                if num[j][l] - num[j][k-1] - num[i-1][l] + num[i-1][k-1] >= K:
                    can.append((x[j]-x[i])*(y[l]-y[k]))
for i in range(len(x)):
    for j in range(1,len(y)-1):
        for k in range(j+1,len(y)):
            if num[i][k] - num[i][j-1] >= K:
                can.append((x[i]-x[0])*(y[k]-y[j]))

for i in range(1,len(x)-1):
    for j in range(i+1,len(x)):
        for k in range(len(y)):
            if num[j][k] - num[i-1][k] >= K:
                can.append((x[j]-x[i])*(y[k]-y[0]))

for i in range(len(x)):
    for j in range(len(y)):
        if num[i][j] >= K:
            can.append((x[i]-x[0])*(y[j]-y[0]))


#print("x",x)
#print("y",y)
#print("data",data)
#print("num",num)
#print("can",can)
print(min(can))

Measured memory_bytes: 91916
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


ll gcd(ll a,ll b){
    if(b == 0){
        return a;
    }else{
        return gcd(b, a%b);
    }
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n, q;
    cin>>n>>q;
    string s;
    cin>>s;
    vector<ll> a(n);
    a[0] = 0;
    ll count = 0;
    for(ll i=1;i<n;++i){
        if(s[i-1] == 'A' and s[i] == 'C'){
            count++;
        }
        a[i+1] = count;
    }
    for(ll i=0;i<q;++i){
        ll l, r;
        cin>>l>>r;
        ll ans = a[r] - a[l];
        cout<<ans<<endl;
    }

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define fast_io cin.tie(0);ios_base::sync_with_stdio(0);
string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cout << endl; }
void show() { cout << endl; }
void pret() { cout << endl; exit(0);}
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cout << " " << to_string(H); debug_out(T...);}
template <typename Head, typename... Tail> void show(Head H, Tail... T) {cout <<H<<" "; show(T...);}
template <typename Head, typename... Tail> void pret(Head H, Tail... T) {cout <<H<<" "; pret(T...);}
#define pr(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
typedef long long ll;
#define int ll
typedef long double ld;
typedef vector<int> vi;
#define disp(x) cout<<x<<" ";
#define rep(i,a,b) for(int i=a;i<(int)b;i++)
#define fo(i,a,b) for(int i=a;i<=(int)b;i++)
#define rf(i,a,b) for(int i=a;i>=(int)b;i--)
#define mp make_pair
#define pb emplace_back
#define F first
#define S second
#define endl '\n'
//cout.setf(ios::fixed);cout.precision(18)
const int MOD = 1e9+7;
const int maxn = 300000+10;

bool f(){
    vector<bool> v;
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        int x, y;
        cin >> x >> y;
        if(x == y) v.emplace_back(1);
        else v.emplace_back(0);
    }
    fo(i, 2, n - 1){
        if(v[i] and v[i - 1] and v[i - 2]) return 1;
    }
    return 0;
}

int32_t main(){
    fast_io;
    if(f()){
        show("Yes");
    }
    else show("No");
    return 0;
}

Measured memory_bytes: 3656
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.sqrt

fun main(args: Array<String>) {

    // IO Templates
    val br = BufferedReader(InputStreamReader(System.`in`))
    val out = PrintWriter(System.out)

    val n = br.readLine()!!.toInt()
    var cnt = 0
    var ok = false
    for (i in 1..n) {
        val (d1, d2) = br.readLine()!!.split(' ').map { it.toInt() }
        if (d1 != d2) {
            cnt = 0
        } else {
            cnt++
            if (cnt == 3) ok = true
        }
    }

    out.println(if (ok) "Yes" else "No")

    out.flush()
}

Measured memory_bytes: 36404
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + end + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException ‚There is no more input";}else{var returnInput = this.list[this.index++];return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var N = nextInt();
  var list = nextIntArray();
  var newlist = new Array(N);
  newlist[0] = list[0];
  for(var i = 1; i < N; i++){
    newlist[i - 1] = Math.min(newlist[i - 1], list[i - 1]);
    newlist[i] = list[i - 1];
  }
  var output = 0;
  for(var i = 0; i < N; i++){
    output += newlist[i];
  }
  myout(output);
}

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

int main(){
	
	int n;
	int in[6000],ans;
	
	while(cin>>n,n){
		for(int i=0;i<n;i++){
			cin>>in[i];
		}
		ans=in[0];
		for(int i=0;i<n;i++){
			int sum=0;
			for(int j=i;j<n;j++){
				sum=sum+in[j];
				ans=max(sum,ans);
			}
		}
		
		cout<<ans<<endl;
	}
	return 0;
}
  

Measured memory_bytes: 1176
def dic(s):
  dics,ans=[],""
  for i in range(len(s)):dics.append(s[i])
  dics.sort()
  for i in dics:ans+=i
  return ans
n=int(input())
s=[dic(input())for _ in range(n)]
s.sort()
a=b=1
c=""
for i in range(n):
  if c!=s[i]:
    b+=a*(a-1)//2
    a=1
    c=s[i]
  else:a+=1
b+=a*(a-1)//2
print(b-1)

Measured memory_bytes: 10736
n, m = map(int, input().split())
start = []
for i in range(n):
    a, b = map(int, input().split())
    start.append([a, b])
check = []
for i in range(m):
    c, d = map(int, input().split())
    check.append([c, d])

for a, b in start:
    distance = 1001001001
    ans = 0
    for i in range(len(check)):
        c, d = check[i][0], check[i][1]
        if abs(a - c) + abs(b - d) < distance:
            distance = abs(a - c) + abs(b - d)
            ans = i + 1
    print(ans)


Measured memory_bytes: 9152
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>

int h, w;
vector<vector<bool>> v;
vector<string> s;
ll ans = 0, a = 0, b = 0;

void dfs(int x, int y) {
    if (s[x][y] == '#') a++;
    else b++;
    int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
    v[x][y] = 1;
    for (int i = 0; i < 4; i++) {
        int nx = x + dx[i], ny = y + dy[i];
        if (nx == -1 || nx == h || ny == -1 || ny == w) continue;
        if (!v[nx][ny]) {
            if (s[x][y] == '.' && s[nx][ny] == '#') {
                dfs(nx, ny);
            }
            else if (s[x][y] == '#' && s[nx][ny] == '.') {
                dfs(nx, ny);
            }
        }
    }
}

int main() {
    cin >> h >> w;
    s.resize(h);
    vector<bool> tmp(w, 0);
    v.assign(h, tmp);
    for (int i = 0; i < h; i++) cin >> s[i];

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            a = b = 0;
            if (s[i][j] == '#') dfs(i, j);
            ans += a * b;
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 25472
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAX  20000

class Message{
    public:
    int t, s, d;
    Message(){}
    bool operator < ( const Message &m ) const{
	return t < m.t;
    }
};

int N, M;
bool infected[MAX];
Message messages[MAX];

main(){
    while(1){
	scanf("%d %d", &N, &M);
	if ( N == 0 && M == 0 ) break;
	for ( int i = 0; i < M; i++ ){
	    scanf("%d %d %d", &messages[i].t, &messages[i].s, &messages[i].d);
	}

	sort( messages, messages + M );
	for ( int i = 0; i < N; i++ ) infected[i] = false;

	infected[0] = true;

	for ( int i = 0; i < M; i++ ){
	    int s = messages[i].s - 1;
	    int d = messages[i].d - 1;
	    if ( infected[s] ) infected[d] = true;
	}

	int sum = 0;
	for ( int i = 0; i < N; i++ ) if ( infected[i] ) sum++;
	printf("%d\n", sum);
    }
}

Measured memory_bytes: 1012
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

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; }
typedef long long ll;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

typedef std::pair<int,int> P;

int N,T;
std::vector<std::vector<ll>> dp;
std::vector<P> F;

ll sol(int n, int w){
  if ( n == 0 ) return 0;
  if ( dp[n][w] != -1 ) return dp[n][w];

  if ( w != 0 ) {
    int wnext = w-F[n-1].first;
    if ( wnext < 0 ) wnext = 0;
    ll rtn = std::max( sol(n-1, wnext)+F[n-1].second, sol(n-1,w) );
    return dp[n][w] = rtn;
  }
  else return dp[n][w] = sol(n-1, w);
}

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  std::cin >> N >> T;
  dp.resize(N+1, std::vector<ll>(T+1,-1));
  F.resize(N);
  rep(i,N) std::cin >> F[i].first >> F[i].second;

  std::sort( all(F), [](P &x, P &y) { return x.first > y.first; });
  //rep(i,N) std::cout << F[i].first << " " << F[i].second << std::endl;

  std::cout << sol(N, T) << std::endl;

  return 0;
}


Measured memory_bytes: 70912
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<cstring>

#define MOD 1000000007

using namespace std;

int main()
{
	long long n;

	scanf("%lld", &n);

	long long bits[60] = { 0, };

	for (long long i = 0; i < n; i++)
	{
		long long input;

		scanf("%lld", &input);

		int idx = 0;

		while (input)
		{
			bits[idx++] += input % 2;

			input /= 2;
		}
	}

	long long sol = 0;
	long long cur = 1;

	for (int i = 0; i < 60; i++)
	{
		sol = (sol + (bits[i] * (n - bits[i]) % MOD) * cur % MOD) % MOD;

		cur = cur * 2 % MOD;
	}

	printf("%lld\n", sol);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 2e6+5;
const ll mod =   1e9+7;

int main()
{  fast

int a;
cin>>a;
cout<<a+a*a+a*a*a;
}

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

int main()
{
    string ans="No";
    int a, b, c;
    cin >> a >> b >> c;
    if(a+b==c||b+c==a||c+a==b){
        ans = "Yes";
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#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>;

int main(){
	int n, k, s;
	cin >> n >> k >> s;
	if(s > 100000){
		rep(i, k) cout << s << ' ';
		rep(i, n-k) cout << 1 << ' ';
	}else{
		rep(i, k) cout << s << ' ';
		rep(i, n-k) cout << 1000000000 << ' ';
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1280
#グラフを書いて前から順番に埋めていけば良さげ
N = int( input())
S = list( input())
X = [0]
now = S[0]
cnt = 0
for k in S:
    if k != now:
        X.append(cnt)
        now = k
    if k == '(':
        cnt += 1
    else:
        cnt -= 1
else:
    if X[-1] != cnt:
        X.append(cnt)
m = min(X)

if m < 0:
    X = list(map( lambda x: x-m, X))

if X[0] != 0:
    if X[0] <= X[1]:
        X[0] = 0
    else:
        X.insert(0,0)
if X[-1] != 0:
    if X[-2] <= X[-1]:
        X.append(0)
    else:
        X[-1] = 0
L = len(X)
up = 'up'
down = 'down'
updown = up

ans = ''
L = len(X)
for i in range(1,L):
    if updown == up:
        ans += '('*(X[i] - X[i-1])
        updown = down
    else:
        ans += ')'*(X[i-1] - X[i])
        updown = up
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int i,N,b=0,r=0;
  string ss;
  cin>>ss;
  N=ss.size();
  for(i=0;i<N;i++){
    if(ss[i]=='0'){b++;}
    else{r++;}
  }
  cout << min(b,r)*2 <<endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	string s;
	cin>>s;
	if(s.substr(0,4)=="YAKI")cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;	
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] a = new int[n][2];
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            int l = sc.nextInt();
            a[i][0] = x-l;
            a[i][1] = x+l;
        }
        Arrays.sort(a,(x, y) -> x[0] - y[0]);
        int ans = 0;
        int l = a[0][0];
        int r = a[0][1];
        for (int i = 1; i < n; i++) {
            if(r <= a[i][0]){
                l = a[i][0];
                r = a[i][1];
            }else{
                ans++;
                if(a[i][1] < r){
                    l = a[i][0];
                    r = a[i][1];
                }
            }
        }
        System.out.println(n - ans);
        sc.close();

    }

}


Measured memory_bytes: 92880
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int w = scanner.nextInt();
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int ans = 0;

		if (b + w < a) {
			ans = a - (b + w);
		} else if (a + w < b) {
			ans = b - (a + w);
		} else {
			ans = 0;
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 21716
#include <iostream>
#include <string>
using namespace std;
int n, a, b, c, d;
string s;
int main() {
	cin >> n >> a >> c >> b >> d;
	a--; b--; c--; d--;
	cin >> s;
	if (b == d) {
		cout << "No\n";
	}
	else if (b < d) {
		bool pos = true;
		for (int i = a + 1; i <= b; i++) {
			if (s[i] == '#' && s[i - 1] == '#') {
				pos = false;
			}
		}

		for (int i = c + 1; i <= d; i++) {
			if (s[i] == '#' && s[i - 1] == '#') {
				pos = false;
			}
		}		
		if (pos && s[c] != '#' && s[d] != '#')
			cout << "Yes\n";
		else cout << "No\n";
	} else {
		bool pos = true;
		bool hashole = false;
		for (int i = a + 1; i <= b; i++) {
			if (s[i] == '#' && s[i - 1] == '#') {
				pos = false;
			}
		}

		for (int i = c + 1; i <= d; i++) {
			if (s[i] == '#' && s[i - 1] == '#') {
				pos = false;
			}
		}	
		for (int i = c + 1; i <= d + 1; i++) {
			if (s[i] == '.' && s[i - 1] == '.' && s[i - 2] == '.') {
				hashole = true;
			}
		}	
		if (hashole && pos && s[c] != '#' && s[d] != '#') {
			cout << "Yes\n";
		}
		else {
			cout << "No\n";
		}
	}

}

Measured memory_bytes: 640
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using Graph = std::vector<std::vector<int>>;
using WGraph = std::vector<std::vector<std::pair<int, long long>>>;
using ll = long long;
using namespace std;

int main() {
    int h = 0, w = 0;
    cin >> h >> w;
    vector<vector<int>> coin(h, vector<int>(w));
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            cin >> coin.at(i).at(j);
        }
    }
    int cnt = 0;
    vector<vector<int>> res;
    for (int i=0; i<h; i++) {
        int dis = 0, j = 0, stop = 0;
        if (i%2 == 0) dis = 1, j = 0, stop = w-1;
        else dis = -1, j = w-1, stop = 0;
        for ( ; j!=stop; j+=dis) {
            if (coin.at(i).at(j)%2 == 1) {
                cnt++;
                coin.at(i).at(j+dis)++;
                res.push_back({i, j, i, j+dis});
            }
        }
        if (i != h-1 && coin.at(i).at(j)%2 == 1) {
            cnt++;
            coin.at(i+1).at(j)++;
            res.push_back({i, j, i+1, j});
        }
    }
    cout << cnt << endl;
    for (auto vec : res) {
        for (int i=0; i<4; i++) {
            cout << vec.at(i) + 1;
            if (i == 3) cout << endl;
            else cout << " ";
        }
    }
    return 0;
}


Measured memory_bytes: 9904
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 1009;
ll i,j,n,ans;
bool visit[N];
ll dp[N],v[N],c[N];
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n;
    rep(i,1,n + 1) cin>>v[i];
    rep(i,1,n + 1) cin>>c[i];
    rep(i,1,N) dp[i] = MAX;
    visit[0] = 1;
    rep(i,1,n + 1) for(j = N - 1;j >= v[i];j -= 1){
        if(visit[j - v[i]]){
            dp[j] = min(dp[j], dp[j - v[i]] + c[i]);
            visit[j] = 1;
        }
    }
    rep(i,1,N) if(visit[i]) ans = max(ans,i - dp[i]);
    cout<<ans;
    return 0;
}

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

using namespace std; 

int main()
{
	int n,maxi=-1,aux=0;
	cin>>n;
	vector<int>v(n);
	for(int i=0;i<n;i++)
		cin>>v[i];
	for(int i=0;i<n-1;i++)
	{
	//	cout<<v[i]<<" "<<v[i+1]<<endl;
		
		if(v[i]>=v[i+1])
		{
			aux++;
			//cout<<"aux: "<<aux<<endl;
		}
		
		else
		{
			if(aux>maxi)
				maxi=aux;
			aux=0;
		}
		
	}
	if(aux>maxi)
		maxi=aux;
	
	cout<<maxi<<endl;
	return 0;		
}




Measured memory_bytes: 640
#include <set>
#include <iostream>

#define int long long

using namespace std;

const int N = 2e5 + 10;

int a[N], b[N];

int32_t main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);    
    int n, m, k;
    cin >> n >> m >> k;
    for (int i = 1; i <= n; ++i)
    {
        cin >> a[i];
        a[i] += a[i - 1];
    }
    set<pair<int, int>> s;
    for (int i = 1; i <= m; ++i)
    {
        cin >> b[i];
        b[i] += b[i - 1];
        s.insert({b[i], i});
    }
    int ans = 0;
    for (int i = 0; i <= n && a[i] <= k; ++i)
    {
        int x = k - a[i];
        auto it = s.lower_bound({x, -1});
        int d = 0;
        if (it != s.end())
        {
            if (it->first > x)
            {
                if (it == s.begin()) 
                {
                    ans = max(ans, i);
                    continue;
                }    
                --it;
            }
        }
        else --it;
        d = it->second;
        ans = max(ans, i + d);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 19276
s = input()
t = input()


ans = "No"
for i in range(len(s)):
    tmp = ''
    for j in range(len(s)):
        if i+j < len(s):
            tmp += t[i+j]
        else:
            tmp += t[i+j-len(s)]
    if tmp == s:
        ans = "Yes"

print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

typedef pair<int, int> P;

int main() {
  int n,m; cin >> n >> m;
  set<int> LEN, IDX;

  int r = n-1;
  loop(l,1,n) {
    if (m==0) break;
    if (IDX.count(l)) continue; // この左は使用済み
    while (r-l==n-(r-l) or IDX.count(r) or LEN.count(r-l)) r--;
    LEN.insert(r-l);
    LEN.insert(n-(r-l));
    IDX.insert(l);
    IDX.insert(r);
    m--;
    cout << l << " " << r << endl;
  }
  return 0;
}


Measured memory_bytes: 20452