akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<deque>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;
typedef deque<int> di;

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

int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};
string t = "ESWN";
signed main(void) {
    int i,j;
    int n,d;
    while(cin >> n >> d, n){
        vector<vi> v(n);
        vi sum(n);
        rep(i,n){
            int m;
            cin >> m;
            vi in(m);
            int s = 0;
            rep(j,m){
                cin >> in[j];
                s += in[j];
            }
            v[i] = in;
            sum[i] = s;
        }
        bool ans = true;
        while(ans){
            int ma = 0, mi = LINF;
            map<int,int> mp;
            rep(i,n)if(v[i].size()){
                ma = max(ma,sum[i]);
                mi = min(mi,sum[i]);
                mp[sum[i]]++;
            }
            if(ma == 0)break;
            if(ma-mi > d)ans = false;
            int sec = 0;
            if(mp[ma] >= 2){
                sec = ma;
            }else{
                rep(i,n)if(sum[i] != ma) sec = max(sec,sum[i]);
            }
            bool c = false;
            rep(i,n)if(v[i].size()){
                if(sum[i] == ma){
                    int ne = sum[i] - v[i].back();
                    if(sec - ne <= d){
                        sum[i] = ne;
                        v[i].pop_back();
                        c = true;
                        break;
                    }
                }else{
                    int ne = sum[i] - v[i].back();
                    if(ma - ne <= d){
                        sum[i] = ne;
                        v[i].pop_back();
                        c = true;
                        break;
                    }
                }
            }
            if(c == false) ans = false;
        }
        if(ans) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}



Measured memory_bytes: 3228
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main implements Runnable {

	int N,Q;

	static class SimpleSegTree {
		static int DEF = Integer.MAX_VALUE;
		int[] seg;
		int n;

		public SimpleSegTree(int size,int fill){

			n = 1;
			while(n < size){
				n <<= 1;
			}

			seg = new int[2 * n - 1];
			Arrays.fill(seg,fill);
		}

		public void set(int ind,int val){

			ind += n - 1;
			seg[ind] = val;

			while(ind > 0){

				ind = ind-1 >> 1;
				seg[ind] = Math.min(seg[ind * 2 + 1],seg[ind * 2 + 2]);
			}
		}

		public int query(int a,int b,int k,int l,int r){

			if(r <= a || b <= l){
				return DEF;
			}

			if(a <= l && r <= b){
				return seg[k];
			}

			int left = query(a,b,k * 2 + 1,l,(l+r)>>1);
			int right = query(a,b,k * 2 + 2,(l+r)>>1,r);

			return Math.min(left, right);
		}

		public int min(int l,int r){
			return query(l,r,0,0,n);
		}
	}


	public void solve() {
		N = nextInt();
        Q = nextInt();

        SimpleSegTree segTree = new SimpleSegTree(N,Integer.MAX_VALUE);

        for(int i = 0;i < Q;i++){
            int c = nextInt();
            int x = nextInt();
            int y = nextInt();

            if(c == 0){
                segTree.set(x,y);
            }else{
                out.println(segTree.min(x,y+1));
            }
        }

	}

	public static void main(String[] args) {
		new Thread(null, new Main(), "", 32 * 1024 * 1024).start();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

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

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

	@Override
	public void run() {
		out.flush();
		new Main().solve();
		out.close();

	}
}

Measured memory_bytes: 62748
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    
    if(N<=111){
    System.out.println("111");
    }else if(112<=N && N<=222){
    System.out.println("222");
    }else if(223<=N && N<=333){
    System.out.println("333");
    }else if(334<=N && N<=444){
    System.out.println("444");
    }else if(445<=N && N<=555){
    System.out.println("555");
    }else if(556<=N && N<=666){
    System.out.println("666");
    }else if(667<=N && N<=777){
    System.out.println("777");
    }else if(778<=N && N<=888){
    System.out.println("888");
    }else{
    System.out.println("999");   
        }
    }
}

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

void merge(vector<int> &arr,int left, int mid, int right,long long &count){
    int n = mid - left;
    int m = right - mid;
    vector<int> right_array(m),left_array(n);
    for(int i=0;i<n;i++) left_array.at(i) = arr.at(left+i);
    for(int i=0;i<m;i++) right_array.at(i) = arr.at(mid + i);
    left_array.push_back(2147483647);
    right_array.push_back(2147483647);
    int i=0,j=0;
    for(int k=left;k<right;k++){
        if(left_array.at(i) > right_array.at(j)){
            arr.at(k) = right_array.at(j);
            j++;
            count += (n-i);
        }else{
            arr.at(k) = left_array.at(i);
            i++;
        }
    }
}

void mergesort(vector<int> &arr, int left,int right,long long &count){
    if(left + 1 < right){
        int mid = (left + right) / 2;
        mergesort(arr,left,mid,count);
        mergesort(arr,mid,right,count);
        merge(arr,left,mid,right,count);
    }
}

int main(){
    int n;
    cin >> n;
    vector<int> array(n);
    for(int i=0; i<n; i++) cin >> array.at(i);
    long long c = 0;
    mergesort(array,0,n,c);
    cout << c << endl;
}


Measured memory_bytes: 5264
#include<bits/stdc++.h>
#define faster  ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
using namespace std;

int main()
{
    faster

    int n,t;
    cin>>n>>t;

    int a[n];
    int mpf,mn,pf,c;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];

        if(i==0)
        {
            mn=a[i];
            pf=0;
            mpf=0;
            c=1;

        }
        else
        {
            if(a[i]<mn)
                mn=a[i];


            if(a[i]>=mn)
            {
                pf=a[i]-mn;
            }

            if(pf>=mpf)
            {
                if(pf==mpf)
                {
                    c++;
                }
                else
                    c=1;

                mpf=pf;
            }

        }

        //cout<<a[i]<<" "<<mpf<<endl;



    }

    cout<<c<<endl;






    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 3123
vpii v;
int a[N] = {}, b[N] = {};

int main(){
	int n, t; scanf("%d%d", &n, &t);
	REP(i, n){
		int a, b; scanf("%d%d", &a, &b);
		v.EB(a, b);
	}
	sort(ALL(v));
	int ans = 0;
	for(auto &p : v){
		REP(i, t){
			if(a[i] + p.second > ans){
				DEBUG("now (%d, %d), a[%d] = %d\n", p.first, p.second, i, a[i]);
			}
			LAR(ans, a[i] + p.second);
			b[i] = a[i];
			if(i) LAR(b[i], a[i-1]);
			if(i >= p.first) LAR(b[i], a[i-p.first] + p.second);
		}
		swap(a, b);
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1<<30;
const ll MOD = 1000000007;

int main(void) {

    int n; cin >> n;
    vi str(5, 0);
    rep(i, n){
        string s; cin >> s;
        if (s == "AC") str[0]++;
        else if (s == "WA") str[1]++;
        else if (s == "TLE") str[2]++;
        else if (s == "RE") str[3]++;
    }

    cout << "AC x " << str[0] << endl;
    cout << "WA x " << str[1] << endl;
    cout << "TLE x " << str[2] << endl;
    cout << "RE x " << str[3] << endl;


    return 0;
}

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

int main()
{
	vector<int> a(3);
	for(int i = 0;i<3;i++)cin >> a[i];
	sort(a.begin(),a.end());
	cout<<3-(a[0]==a[1])-(a[1]==a[2])<<endl;
}


Measured memory_bytes: 3596
S = input()
T = input()

for i in range(len(S)-len(T)+1)[::-1]:
    tmp = S[i:i+len(T)]
    flag = True

    for j in range(len(T)):
        if tmp[j]!=T[j] and tmp[j]!='?':
            flag = False
            break

    if flag:
        w = S[:i] + T + S[i+len(T):]
        w = w.replace('?', 'a')
        print(w)
        exit()

print('UNRESTORABLE')

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
       Scanner sc = new Scanner(System.in);
        String h = sc.nextLine();
        String s = sc.nextLine();
        int k = Integer.parseInt(h);
        int len = String.valueOf( s ).length();
        if (len <= k) {
            System.out.println(s);
        } else {
            for (int i = 0; i < k; i++) {
                System.out.print(s.charAt(i));
            }
            System.out.print("...");
        }
        
    }
}


Measured memory_bytes: 35736
# coding:utf-8

import sys
import math
import time
import numpy as np
import collections
from collections import deque
import queue
import copy

# 最大公約数
def gcd(m,n):
  x = max(m,n)
  y = min(m,n)
  if x%y == 0:
    return y
  else:
    while x%y != 0:
      z = x%y
      x = y
      y = z
    else:
      return z

# 幅優先探索(BFS)でスタート座標(x, y)からの最大距離返す
def bfs(SS, x, y, H, W):#入力(座標系(迷路), x, y, xの端, yの端)
  x_next = [0, 0, -1, 1]
  y_next = [1, -1, 0, 0]
  tempx = x
  tempy = y
  mlength = 0
  q = deque()
  xytuple = (x, y, 0)
  q.append(xytuple)


  while q:
    xytuple = q.popleft()
    SS[xytuple[0]][xytuple[1]] = "x" #探索した場所は探索できないようにする
    for i in range(4): #このforで上下左右を調べてる
      tempx = xytuple[0] + x_next[i]
      tempy = xytuple[1] + y_next[i]
      #print(tempx, tempy, xytuple[2])
      #print(S)
      if(0 <= tempx and tempx < H and 0 <= tempy and tempy < W and SS[tempx][tempy] == "."):
        temptuple = (tempx, tempy, xytuple[2]+1)
        SS[temptuple[0]][temptuple[1]] = "x" #探索した場所は探索できないようにする
        mlength = max(mlength, xytuple[2] +1)
        q.append(temptuple)
      #print(q)
  return mlength

def brick(a,n,m,N):#ABC 148
  #n番目以降にmがあるか調べる
  if not m in a[n:]:
    print(N-(m-1))
  else:
    #b = copy.deepcopy(a)
    brick(a,a[n:].index(m),m+1,N)

#X = str(input()).split()
#a = [int(x) for x in input().split()]

N = int(input())
S = []
Mc = 0
Ac = 0
Rc = 0
Cc = 0
Hc = 0
ans = 0

for i in range(N):
    S.append(str(input())[0])
    if(S[i]=="M"):
        Mc +=1
    elif(S[i]=="R"):
        Rc += 1
    elif(S[i]=="A"):
        Ac += 1
    elif(S[i]=="C"):
        Cc += 1
    elif(S[i]=="H"):
        Hc += 1

ans += Mc*Ac*Rc
ans += Mc*Ac*Cc
ans += Mc*Ac*Hc
ans += Mc*Rc*Cc
ans += Mc*Rc*Hc
ans += Mc*Cc*Hc
ans += Ac*Rc*Cc
ans += Ac*Hc*Cc
ans += Ac*Rc*Hc
ans += Cc*Rc*Hc

print(ans)


Measured memory_bytes: 13628
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using static System.Console;

namespace ABC120C
{
    static class Program
    {
        static void Main(string[] args)
        {
            var s = ReadLine();
            var count0 = s.Count(c => c == '0');
            var count1 = s.Length - count0;

            WriteLine($"{2 * Math.Min(count0, count1)}");

        }

        public static T TryParse<T>(this String input)
        {
            try
            {
                var converter = TypeDescriptor.GetConverter(typeof(T));
                if (converter != null)
                {
                    return (T)converter.ConvertFromString(input);
                }
                else
                {
                    throw new InvalidCastException("");
                }
            }
            catch
            {
                throw new InvalidCastException(typeof(T) + " is not supported.");
            }
        }

        public static List<T> SplitTryParseToList<T>(this String input)
        {
            return input.Split().Select(n => n.TryParse<T>()).ToList();
        }

        public static List<T> ListSwap<T>(this List<T> list, Int32 index1, Int32 index2)
        {
            var t = list[index1];
            list[index1] = list[index2];
            list[index2] = t;
            return list;
        }

        public static List<Tuple<T, int>> DuplicateCount<T>(this IEnumerable<T> list)
        {
            return list
                .GroupBy(i => i)
                .Where(g => g.Any())
                .Select(g => Tuple.Create(g.Key, g.Count()))
                .ToList();
        }
        public static List<Tuple<T, int>> DuplicateSort<T>(this IEnumerable<Tuple<T, int>> list)
        {
            return list.OrderByDescending((x) => x.Item2).ToList();
        }
        public static List<T> ReadLineOne<T>(int n)
        {
            var list = new List<T>();
            foreach (var i in Enumerable.Range(1, n))
            {
                list.Add(Console.ReadLine().TryParse<T>());
            }
            return list;
        }
        public static void PrintAll<T>(this IEnumerable<T> list)
        {
            foreach (var i in list)
            {
                Console.Write($"{i} ");
            }

            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 13276
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
using namespace std;

int main(){
  int a,b; cin>>a>>b;
  //偶奇が違うとき
  if(a%2!=b%2) cout<<"IMPOSSIBLE"<<endl;
  else cout<<(a+b)/2<<endl;
  return 0;
}

Measured memory_bytes: 256
// 　　＿＿
// 　／　<＠ﾌ
//  ｜(ﾉﾉハ))
//  ﾉ从ﾟヮﾟ从
// 　ﾉ｜ｿﾉГ|つ author:hotarunx
// 〈_ﾉ^^^ヽ|
// 　~~tｧtｧ~
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

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

    int h, w, m;
    cin >> h >> w >> m;

    vector<int> rowbombs(h), columnbombs(w);
    set<pair<int, int>> monsexist;

    for (int i = 0; i < m; i++) {
        int hi, wi;
        cin >> hi >> wi;
        hi--, wi--;

        rowbombs[hi]++;
        columnbombs[wi]++;
        monsexist.insert({hi, wi});
    }

    int ans = 0;

    const int maxrowbombs = *max_element(rowbombs.begin(), rowbombs.end());
    const int maxcolumnbombs =
        *max_element(columnbombs.begin(), columnbombs.end());

    vector<int> rr, cc;
    rr.reserve(m);
    cc.reserve(m);

    for (int i = 0; i < h; i++) {
        if (rowbombs[i] == maxrowbombs) rr.emplace_back(i);
    }
    for (int i = 0; i < w; i++) {
        if (columnbombs[i] == maxcolumnbombs) cc.emplace_back(i);
    }

    bool cross = true;

    for (auto &&i : rr) {
        for (auto &&j : cc) {
            if (monsexist.count({i, j}) == 0) {
                cross = false;
            }

            if (!cross) break;
        }
        if (!cross) break;
    }

    ans = maxrowbombs + maxcolumnbombs;
    if (cross) ans--;

    cout << ans << endl;
}


Measured memory_bytes: 31400
import heapq
def resolve():
    n,m=map(int,input().split())
    drink=[]
    ans=0
    count=0
    for i in range(n):
        tmp=list(map(int,input().split()))
        drink.append(tmp)
    heapq.heapify(drink)
    while(True):
        tmp=heapq.heappop(drink)
        if m>tmp[1]:
            ans+=tmp[0]*tmp[1]
            m-=tmp[1]
        else:
            ans+=tmp[0]*m
            break
    print(ans)


resolve()

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

int main() {
int N;cin>>N;
vector<int>p(N);
for(int i = 0; i <N; i++)
{
    cin>>p.at(i);
}
sort(p.begin(),p.end());
int herf=p.at(N-1)/2;
for(int i = 0; i < N-1; i++)
{
   herf+=p.at(i);
}
 cout<<herf<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    Main(){
	int n, s, t, u, v;
	Scanner sc = new Scanner(System.in);
	int[] score, rank;

	while(sc.hasNext()){
	    n = sc.nextInt();
	    score = new int[n];
	    rank = new int[n];

	    for(int i = 0; i < (n*(n-1))/2; ++i){
		s = sc.nextInt();
		t = sc.nextInt();
		u = sc.nextInt();
		v = sc.nextInt();

		if(u == v) u = v = 1;
		else if(u < v){ u = 0; v = 3;} 
		else {u = 3; v = 0;}

		score[s-1] += u;
		score[t-1] += v;
	    }
	    s = 0;
	    for(int i = 0; i < n; ++i)
		s = Math.max(s, score[i]);

	    t = 1;
	    for(int i = s; i >= 0; --i){
		u = 0;
		for(int j = 0; j < n; ++j)
		    if(score[j] == i){
			rank[j] = t;
			++u;
		    }
		t += u;
	    }

	    for(int i = 0; i < n; ++i)
		System.out.printf("%d\n", rank[i]);
	}
    }

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

Measured memory_bytes: 0
if __name__ == "__main__":
    
    n = int(input())

    """for o in range(1, n+1):
        s = 1
        if o > 6:
            s = -1 + int((o-2)**0.5)
        for x in range(s, 100):
            isFound = False
            for y in range(1, x+1):
                for z in range(1, y+1):
                    m = x**2+y**2+z**2+x*y+y*z+z*x
                    if m == o:
                        isFound = True
                        if x==y and y==z: print(1)
                        elif x==y or y==z or z==x: print(3)
                        else: print(6)
                        break
                    elif m > o:
                        break
                if isFound: break
            if isFound: break
        if not isFound: print(0)"""

    ans = [0 for _ in range(10001)]
    for x in range(1, 101):
        for y in range(1, 101):
            for z in range(1, 101):
                m = x**2+y**2+z**2+x*y+y*z+z*x
                if m > 10000: break
                ans[m] += 1

    for i in range(n):
        print(ans[i+1])

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

int main(){
  int n;
  cin >> n;
  vector<tuple<string, int, int>> restaurant(n);
  rep(i, n){
      string s;
      int p;
      cin >> s >> p;
      restaurant[i] = make_tuple(s, 100-p, i+1);
  }
  sort(restaurant.begin(), restaurant.end());

  rep(i, n){
      cout << get<2>(restaurant[i]) << endl;
  }
  return 0;
  
}


Measured memory_bytes: 256
using System;
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int a, b,c;
            a = int.Parse(s[0]);
            b = int.Parse(s[1]);
            c = int.Parse(s[2]);
            if (a < b && b < c)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }

Measured memory_bytes: 19624
use std::io::{self, BufRead};

fn main() {
    let stdin = io::stdin();
    let mut lines = stdin.lock().lines();
    let h_n = lines.next().unwrap().unwrap();
    let mut h_n = h_n.split_whitespace();
    let h: i32 = h_n.next().unwrap().parse().unwrap();
    let _: i32 = h_n.next().unwrap().parse().unwrap();
    let a_sum: i32 = lines
        .next()
        .unwrap()
        .unwrap()
        .split_whitespace()
        .map(|s| s.parse::<i32>().unwrap())
        .sum();
    let ans = if h - a_sum <= 0 { "Yes" } else { "No" };
    println!("{}", ans);
}


Measured memory_bytes: 4352
#abc107  b
h,w=map(int,input().split())
a=[]
gyo=[False]*h
for i in range(h):
    line=input()
    a.append(line)
    if line.count(".")==w:
        gyo[i]=True
retsu=[False]*w
for i in range(w):
    cnt=0
    for j in range(h):
        if a[j][i]==".":
            cnt+=1
    if cnt==h:
        retsu[i]=True

#print(gyo,retsu)
for i in range(h):
    if gyo[i]==False:
        line=""
        for j in range(w):
            if retsu[j]:
                continue
            else:
                line+=a[i][j]
        print(line)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = int64_t;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;


int main() {
    int h, w, s, t;
    cin >> h >> w >> s >> t;
    if(h%s == 0 && w%t == 0) {
        puts("No");
        return 0;
    }
    puts("Yes");
    int a = 500000000/(s*t-1), b = a*(s*t-1)+1;
    b = -b;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if(j) printf(" ");
            if(i%s == h%s && j%t == w%t) printf("%d", b);
            else printf("%d", a);
        }
        puts("");
    }
    return 0;
}


Measured memory_bytes: 2816
#include <stdio.h>

int main(){
  int N,a[100],flag,i,j,cnt=0,t;

  scanf("%d",&N);

  for(i=0;i < N;i++){
    scanf("%d",&a[i]);
  }
  flag = 1;
  while(flag){
    flag=0;
    for(j=N-1,i=1;j>i-1;j--){
    if(a[j]<a[j-1]){
      t=a[j-1];
      a[j-1]=a[j];
      a[j]=t;
      cnt+=1;
      flag=1;
    }
  }
  i++;}

  for(i=0;i<N;i++){
    printf("%d",a[i]);
    if(i==N-1){
      printf("\n");
    }
    else printf(" ");
  }
  printf("%d\n",cnt);

  return 0;
}

Measured memory_bytes: 604
#include <cstdio>
#include <map>
using namespace std;int main(){
for(int n[1501], m[1501],o,a,b,i,j,x;scanf("%d%d",&a,&b),a;printf("%d\n",o)){
  map<int,int> point;
  map<int,int>::iterator p;

  n[0]=m[0]=o=0;

  for(i=0;i<a;i++){
    scanf("%d", &x);
    n[i+1]=n[i]+x;
  }
  for(i=0;i<b;i++){
    scanf("%d", &x);
    m[i+1]=m[i]+x;
  }
  
  for(i=0;i<=a;i++){
    for(j=0;j<=b;j++){
	  point[n[i]+m[j]]++;
	}
  }
  
  for(p=point.begin(); p!=point.end(); p++){
	o+=(p->second)*((p->second)-1)/2;
  }
}
}

Measured memory_bytes: 18000
#include<string>
#include<vector>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<sstream>
#include<functional>
#include<map>
#include<set>
#include<cmath>

using namespace std;

int main(){

	int a,b; int c=90; double x=0; double y=0;
	while(true){

	scanf("%d,%d",&a,&b);
	if(a==0 && b==0) break;
	x+=a*cos(c*M_PI/180);
	y+=a*sin(c*M_PI/180);
	c-=b;

	}

	printf("%d\n%d\n",(int)x,(int)y);


	return 0;

    }

Measured memory_bytes: 1192
N,A,B=map(int, input().split(" "))

#print(N,A,B)

if A == 0 and B == 0:
    ans = 0
else:
  sho = N // (A+B)
  mod = N % (A+B)
  if mod > A:
  	ans = A * sho + A
  else:
  	ans = A * sho + mod

print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	int minn = 0x3f3f3f3f;
	int sum = 0;
	for(int i = 0; i < n; i++){
		int d;
		scanf("%d",&d);
		if(d<minn){
			sum++;
			minn=d;
		}
	}
	printf("%d\n",sum);
	return 0;
}


Measured memory_bytes: 256
//Optional FAST
 
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")
 
//Required Libraries
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
 
//Required namespaces
 
using namespace std;
using namespace __gnu_pbds;
//typedef
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

//define
#define inp(X) cin>>X;
#define inp_long(X) long long X; cin>>X;
#define inp_arr(A,N) long long A[N]; for(long long int i=0;i<N;i++) {cin>>A[i];}
#define sz(A) A.size()
#define pb push_back
#define pf push_front
#define fi first
#define se second
//#define endl '\n'
#define vect(A) vector<long long> A;
#define inp_vect(A,N); vect(A);for(long long i=0;i<N;i++){long long q; cin>>q; A.push_back(q);}
#define forin(i,a,b) for(long long i=a;i<=b;i++)
#define forde(i,a,b) for(long long i=a;i>=b;i--)
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);

ll power(ll x,ll y)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2) % MOD;
    p = (p * p) % MOD;

    return (y%2 == 0)? p : (x * p) % MOD;
}
ll modInverse(ll a)
{
   return power(a,MOD-2);
}
ll z[1001][11]={0};
int main()
{
   /*#ifndef ONLINE_JUDGE
       freopen ("input.txt" , "r" , stdin);
		// freopen ("OUTPUT.txt" , "w" , stdout);
	#endif 
    */
    fio;
    ll n,m;
    cin>>n>>m;
    if(m==n)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    cout<<endl;
}

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

int main() {
    int n;
    cin >> n;
    pair<pair<string, int>, int> p[105];
    for (int i = 0; i < n; i++) {
        string s;
        int pp;
        cin >> s >> pp;
        p[i] = make_pair(make_pair(s, -pp), i + 1);
    }
    sort(p, p + n);
    for (int i = 0; i < n; i++) {
        cout << p[i].second << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

using namespace std;

const uint64_t MOD = 1e+9 + 7;

uint64_t bin_pow(uint64_t x, uint64_t y)
{
  if (y <= 1) {
    return (y == 0) ? 1 : (x % MOD);
  }

  uint64_t w = bin_pow(x, y >> 1);
  uint64_t z = (w * w) % MOD;

  if (y % 2 == 1) {
    z = (x * z) % MOD;
  }

  return z;
}

uint64_t gcd(int64_t a, int64_t b)
{
  uint64_t n = min(a, b), m = max(a, b);
  return (n == 0) ? m : gcd(m % n, n);
}

struct Rational
{
  int64_t p, q;

  Rational(int64_t p = 0, int64_t q = 0) : p(p), q(q) {
    if (this->q < 0) {
      this->p *= -1;
      this->q *= -1;
    } else if (this->q == 0 && this->p < 0) {
      this->p *= -1;
      this->q *= -1;
    }
    
    int64_t t = gcd(abs(this->p), abs(this->q));
    this->p /= t;
    this->q /= t;
  }

  bool operator==(const Rational &rhs) const {
    return (p == rhs.p) && (q == rhs.q);
  }

  bool operator<(const Rational &rhs) const {
    return (p == rhs.p) ? (q < rhs.q) : (p < rhs.p);
  }
};

int main()
{
  uint64_t N;
  cin >> N;

  uint64_t count_zero_vec = 0;
  multiset<Rational> P;
  N_TIMES(n, N) {
    int64_t A, B;
    cin >> A >> B;

    if (A == 0 && B == 0) {
      ++count_zero_vec;
    } else {
      P.emplace(A, B);
    }
  }

  map<Rational, pair<uint64_t, uint64_t>> counter;
  for (const Rational &p : P) {
    Rational q(-p.q, p.p);
    bool not_find_p = counter.find(p) == counter.end();
    bool not_find_q = counter.find(q) == counter.end();

    if (not_find_p && not_find_q) {
      counter.emplace(p, make_pair(P.count(p), P.count(q)));
    }
  }

  uint64_t S = 1;
  for (auto tuple : counter) {
    uint64_t T = 0;
    auto calc_pow2_sub1 = [&](uint64_t x) { return (bin_pow(2, x) + (MOD - 1)) % MOD; };
    T = (T + calc_pow2_sub1(tuple.second.first) ) % MOD;
    T = (T + calc_pow2_sub1(tuple.second.second)) % MOD;
    T = (T + 1) % MOD;
    S = (S * T) % MOD;
  }
  S = (S + count_zero_vec) % MOD;
  S = (S + (MOD - 1)) % MOD;
  cout << S << endl;

  return 0;
}

Measured memory_bytes: 31516
import math
N = int(input())

sum, ulim = 1, 1
while sum < N:
    ulim += 1
    sum += ulim
Ans = [int(i) for i in range(1, ulim + 1)]
diff = sum - N
if diff > 0:
    Ans.remove(diff)
for a in Ans:
    print(a)

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
int main() {
     int N,M,X;
     cin >> N >> M >> X;
     int l = 0,r = 0;
     vector<int> A(M);
     for(int i = 0; i < M; i++){
          cin >> A[i];
           for(int j = 0; j < X; j++){
                if(j == A[i]) l++;
          }
          for(int k = X; k < N; k++){
               if(k == A[i]) r++;
          }
     }
     cout << min(l,r) << endl;
}

Measured memory_bytes: 256
import Data.List
import Control.Monad

main = do
    n <- readLn :: IO Int
    ws <- lines <$> getContents
    let p1 = and $ zipWith check ws (tail ws)
    let p2 = (== length ws) . length . group $ sort ws
    putStrLn $ if p1 && p2 then "Yes" else "No"

check w1 w2 = l == h
    where l = last w1
          h = head w2

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    ll ans = 0;
    REP(i, N){
        ll l,r;
        cin >> l >> r;
        ans += r-l+1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<60


int main(){
    int N;cin>>N;
    vector<ll> a(N*3);
    vector<ll> L(N*3),R(N*3);
    for(int i = 0; i < N*3 ; i++){
        cin >> a[i];
    }
    priority_queue<ll,vector<ll>,greater<ll>> lque;
    ll sum = 0;
    for(int i = 0; i < N*3 ; i++){
        lque.push(a[i]);
        sum+=a[i];
        if(N < lque.size()){
            ll p = lque.top();
            lque.pop();
            sum -= p;
        }
        L[i] = sum;
    }
    priority_queue<ll> rque;
    sum = 0;
    for(int i = N*3-1 ; i >= 0; i--){
        rque.push(a[i]);
        sum += a[i];
        if(N<rque.size()){
            ll p = rque.top();
            rque.pop();
            sum -= p;
        }
        R[i] = sum;
    }

    ll ans = -INF;
    for(int i = N ; i < N*2+1 ; i++){
        ans = max(ans,L[i-1] - R[i]);
    }


    cout << ans << endl;

    return 0;
}

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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  int n, k, t = 1;
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    if (t < k) t *= 2;
    else t += k;
  }
  cout << t << endl;
}



Measured memory_bytes: 764
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

int main(){
    ll N; cin >> N;
    cout << 180*N - 360 << endl;
    return 0;
}


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

ans = 0
current_height = 0
for i in range(N):
  # h[i-1]までの高さにはh[i]も育っているので、その差分だけ水をやる必要がある
  # current_height は一つ手前の花の高さ
  if h[i] > current_height:
    ans += h[i] - current_height
    current_height = h[i]
  else:
    # i-1番目の花の高さのほうがi番目より高いなら、水を新たにやる必要はない（i-1に水をやるときに同時に達成できるので）
    current_height = h[i]



print(ans)

Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1 << 30;
const ll MOD = 1000000007;
int N, M, Q;
vector<vector<int>> val;

int traverse(int n, int size, vector<int> v) {
  if (size == N) {
    int max = 0;
    for (int i = 0; i < v.size(); i++) {
      // printf("%d", v[i]);
    }
    for (int i = 0; i < Q; i++) {
      if (v[val[i][1] - 1] - v[val[i][0] - 1] == val[i][2]) max += val[i][3];
      // printf("val b = %d, val a = %d\n", val[i][1], val[i][0]);
      // printf("b = %d, a = %d\n", v[val[i][1] - 1], v[val[i][0] - 1]);
    }
    // printf(" max = %d\n", max);
    return max;
  }

  int result = 0;
  for (int i = n; i <= M; i++) {
    vector<int> v2;
    copy(v.begin(), v.end(), back_inserter(v2));
    v2.push_back(i);
    result = max(traverse(i, size + 1, v2), result);
  }
  return result;
}

int main(void) {
  cin >> N >> M >> Q;
  val.resize(Q);

  for (int i = 0; i < Q; i++) {
    val[i].resize(4);
    cin >> val[i][0] >> val[i][1] >> val[i][2] >> val[i][3];
  }

  vector<int> v;

  int max = traverse(1, 0, v);
  cout << max << endl;

  return 0;
}

Measured memory_bytes: 3628
// ######      ###      #######    #######    ##     #     #####        ###     ##### //
// #     #    #   #          #        #       # #    #    #     #      #   #     ###  //
// #     #   #     #        #         #       #  #   #   #       #    #     #    ###  //
// ######   #########      #          #       #   #  #   #           #########    #   //
// #     #  #       #     #           #       #    # #   #    ####   #       #    #   //
// #     #  #       #    #            #       #     ##   #    #  #   #       #        //
// ######   #       #   #######    #######    #      #    #####  #   #       #    #   //

// #pragma GCC optimize(2)
// #pragma GCC optimize(3)
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("avx,avx2,fma")
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> ppl;
#define ain(a,n) for(ll i=0;i<(n);++i)  cin>>(a)[i];
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(ll i=0;i<(n);++i)
#define FOR(i,a,b) for(ll i=(a);i<=(b);++i)
#define FORD(i,a,b) for(ll i=(a);i>=(b);--i)
#define cases ll T=0;cin>>T;while(T--)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define END "\n"
#define pb push_back
#define mp make_pair
#define go(c,itr) for(auto itr=(c).begin(); itr!=(c).end(); ++itr)
// #define back(c,itr) for(auto itr=(c).rbegin(); itr!=(c).rend(); ++itr)
#define PI 3.14159265359
#define inf 9e18
#define MOD 1000000007
#define MODU 998244353
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MAXN 300005
#define BLOCK 555
const string alpha = "abcdefghijklmnopqrstuvwxyz";
const ll N = 200005;
const long double epsilon = 1e-9;
inline ll myceil(ll a, ll  b) {
	return (ceil(1.0 * a / b * 1.0));
}
ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
ll modinvfermat(ll a, ll m)
{
	return binexp(a, m - 2, m);
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}



signed main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	fast
	ll n, x, k;
	cin >> n >> x >> k;
	map<ll, ll> done, ind;
	vl a;
	ll curr = x, i = 1;
	ll ans = x % k;
	while (i < n)
	{
		curr = (curr * curr) % k;
		if (done[curr] == 0)
		{
			ans += curr;
			done[curr] = 1;
			a.pb(curr);
			ind[curr] = ll(a.size()) - 1;
			++i;
		}
		else
			break;
	}
	if (i == n)
		cout << ans << END;
	else
	{
		ll rem = n - i;
		ll start = ind[curr];
		ll len = ll(a.size()) - start;
		ll totsum = 0;
		FOR(i, start, ll(a.size() - 1))	totsum += a[i];
		ans += (rem / len) * totsum;
		FOR(i, start, start + (rem % len) - 1)	ans += a[i];
		cout << ans << END;
	}



// #ifndef ONLINE_JUDGE
//     cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
// #endif
	return 0;
}



Measured memory_bytes: 9836
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    ll N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
        A[i]--;  // 0-indexed に変更
    }
    int logK = 1;
    while ((1LL << logK) < K) logK++;
    // doubling[k][i] : i番目から 2^k 進んだ町
    vector<vector<int> > doubling(logK, vector<int>(N));
    for (int i = 0; i < N; i++) {
        doubling[0][i] = A[i];
    }
    // 前処理 doubling の計算
    for (int k = 0; k < logK - 1; k++) {
        for (int i = 0; i < N; i++) {
            doubling[k + 1][i] = doubling[k][doubling[k][i]];
        }
    }
    int now = 0;
    for (int k = 0; K > 0; k++) {
        if (K & 1) now = doubling[k][now];
        K = K >> 1;
    }
    cout << now + 1 << endl;
}


Measured memory_bytes: 51780
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int a, b, k, cnt = 0;
    scanf("%d%d%d", &a, &b, &k);
    for (int i = min(a, b); i >= 1; --i) {
        if (a % i == 0 && b % i == 0) ++cnt;
        if (cnt == k) {
            printf("%d\n", i);
            return 0;
        }
    }
    return 0;
}


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

int main() {
    int N,M;
    cin >> N >> M;
    int input;
    vector<int> k(M);
    vector<vector<int>> s(M);
    for(int i=0; i<M; i++){
        cin >> k.at(i);
        for(int j=0; j<k.at(i); j++){
            cin >> input;
            s.at(i).push_back(input);
        }
    }
    vector<int> p(M);
    for(int i=0; i<M; i++) cin >> p.at(i);
    
    int ans=0;
    
    for(int bit=0; bit<(1<<N); bit++){
        int cnt=0;
        for(int i=0; i<M; i++){
            int scnt=0;
            for(int j=0; j<k.at(i); j++){
                if(bit & (1<<s.at(i).at(j)-1)) scnt++;
            }
            if(scnt%2==p.at(i)) cnt++;
        }
        if(cnt==M) ans++;
    }
    cout << ans << endl;

}

Measured memory_bytes: 3572
N,M=map(int,input().split())
S=input()
T=input()



for i in range(1,M+1):
    if N*i%M==0:
        break

ANS=N*i

check=1
for i in range(N):
    s=S[i]
    if (i*M)%N==0:
        t=T[(i*M)//N]
        if s!=t:
            check=0
            #print(s,t)
            break

if check==1:
    print(ANS)
else:
    print(-1)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define all(v) v.begin(),v.end()
#define fio() ios::sync_with_stdio(0);cin.tie(0);
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define fornn(i,a,n) for(ll i=a;i<=n;i++)
#define pb push_back
#define MAXN 100005LL
#define INF 1000000005LL
inline void solve(){
	ll a,b,c,x,ans=0;
	cin>>a>>b>>c>>x;
	x/=50;
	for(ll i=0;i<=a;i++)
		for(ll j=0;j<=b;j++){
			ll eq=10*i+2*j;
			if((x-eq)<=c && (x-eq)>=0)
				ans++;
		}
	cout<<ans<<endl;
}
int main(){
	// #ifndef ONLINE_JUDGE
	// freopen("output.txt","w",stdout);
	// freopen("input.txt","r",stdin);
	// #endif
	fio();
	ll t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;

int N;
string S;

int main(){
    cin>>N>>S;

    int ans=0;
    rep(num,1000){
        char a='0'+(num/100);
        char b='0'+num/10%10;
        char c='0'+num%10;
        int cnt=0;
        rep(i,N){
            if(cnt==0 && S[i]==a) cnt++;
            else if(cnt==1&& S[i]==b) cnt++;
            else if(cnt==2&& S[i]==c) cnt++;
            else if(cnt==3) break;
        }
        if(cnt==3) ans++;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
/*Author : Hrishi*/

/*When I wrote this, only God and I understood what I was doing.
Now, only God knows.*/

#include <bits/stdc++.h>

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pi pair<int,int>
#define pl pair<ll,ll> 
#define ff first
#define ss second
#define PB push_back
#define F(i,L,R) for(auto i=L; i<R ;i++)
#define FR(i,R,L) for(auto i=R;i>L;i--)
#define all(x) (x).begin(),(x).end()
#define show(x) cout<<(#x)<<" = "<<(x)<<"\n";
#define show2(x,y) cout<<(#x)<<" = "<<(x)<<" & "<<(#y)<<" = "<<(y)<<"\n";
#define show3(x,y,z) cout<<(#x)<<" = "<<(x)<<" & "<<(#y)<<" = "<<(y)<<" & "<<(#z)<<" = "<<(z)<<"\n";
#define endln "\n"
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define M 1000000007

using namespace std;

int main() 
{
	fastio;
	int test=1;
//	cin>>test;
	while(test--)
	{
	    int a,c;
	    cin>>a>>c;
	    cout<<a*c<<"\n";
	    
	    
	    
	    
	}

}




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

bool dp[30004][10][10][10];

int main() {
  int n;
  cin>>n;
  string S;
  cin>>S;
  dp[3][(int)(S[0]-'0')][(int)(S[1]-'0')][(int)(S[2]-'0')]=true;
  for (int i=3;i<n;i++) {
    rep(a0, 10) {
      rep(a1, 10) {
        rep(a2, 10) {
          dp[i+1][a0][a1][a2] |= dp[i][a0][a1][a2];
          dp[i+1][a1][a2][(int)(S[i]-'0')]|=dp[i][a0][a1][a2];
          dp[i+1][a0][a2][(int)(S[i]-'0')]|=dp[i][a0][a1][a2];
          dp[i+1][a0][a1][(int)(S[i]-'0')]|=dp[i][a0][a1][a2];
        }
      }
    }
  }
  int ans=0;
  rep(i, 10) {
    rep(j, 10) {
      rep(k, 10) {
        if (dp[n][i][j][k]) ans++;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 29568
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
#include<cstring>
#include<set>
using namespace std;
using ll = long long;
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 (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;
// vector<vector<ll>> vec(100,vector<ll>(3,0));
int main(){
  ll a,b,c;
  cin >> a >> b >> c;
  if(b+c-a > 0){
    cout << b+c-a;
  }else{
    cout << 0;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	private static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		String w = sc.next();
		int[] count = new int[26];
		for (int i = 0; i < w.length(); i++) {
			count[w.charAt(i) - 'a']++;
		}
		for (int i = 0; i < 26; i++) {
			if (count[i] % 2 != 0) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
}


Measured memory_bytes: 25172
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

import re
# import numpy as np
# from scipy.misc import perm
# from scipy.misc import comb

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e18)
MOD = int(1e9)+7 # 10^9 + 7

########
N = i_inpl()
def sieve_of_eratosthenes(N):
    prime_table = [True] * N
    prime_table[0] = prime_table[1] = False

    for i, is_prime in enumerate(prime_table):
        if is_prime:
            for n in range(i*i, N, i):
                prime_table[n] = False
    return prime_table

primes = [ i for i, f in enumerate(sieve_of_eratosthenes(55556)) if f]

l = [ str(pi) for pi in primes if pi % 5 == 1]
print(" ".join(l[0:N]))

Measured memory_bytes: 4468