akhauriyash/Code-Regression huggingface dataset:
/*
	ID: sixathofpain
	TASK: friday
	LANG: C++   

*/


//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define setbits(x) __builtin_popcount(x)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define in insert
#define pb push_back
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll MOD = 1000000007;
const int N = int(3e5) + 999;
#define int long long int

int32_t main(){
    IOS;
	
    // freopen("friday.in","r",stdin);
    // freopen("friday.out","w",stdout);

    int k,n;
    cin>>k>>n;
    int arr[n];
    for(int i=0;i<n;i++)
    	cin>>arr[i];
    sort(arr,arr+n);
    int ans = 0;
    for(int i=0;i<n-1;i++)
    	ans = max(ans,arr[i+1]-arr[i]);
    ans = max(ans,(k-arr[n-1]+arr[0]));
    cout<<k-ans<<endl;

    return 0;
}

Measured memory_bytes: 1792
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from decimal import Decimal

a, b = map(float, readline().split())
a = Decimal(str(a))
b = Decimal(str(b))
print(int(a * b))


Measured memory_bytes: 10140
#include <stdio.h>
int main(){
 char a[1001];
 int g,i;
 while(1){
  scanf("%s",&a);
  if(a[0]=='0')break;
  g=0;
  for(i=0;a[i]!='\0';i++)
   g+=a[i]-'0';
  printf("%d\n",g);}
}
 


Measured memory_bytes: 2040
N = int(input())
F = [int(''.join(input().split()), 2) for i in range(N)]
P = [list(map(int, input().split())) for i in range(N)]
benefit = -10**9
for i in range(1, 2 ** 10):
    b = 0
    for f, p in zip(F, P):
        count = 0
        for j in range(10):
            if (i & f) >> j & 1:
                count += 1
        b += p[count]
    benefit = max(benefit, b)
print(benefit)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
	   if(x%i==0)return false;
   }return true;
}
bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline ll read() {
	char c = getchar(); ll w = 1; ll x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar();
	x *= w;
}
void fl(string name){
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
int main(){
	fast;
	ll a,b;
	cin>>a>>b;
	if(a==b)cout<<"Yes"<<endl;
	else cout<<"No"<<endl; 
}/*『你强归你强，Siyuan比你强』*/





Measured memory_bytes: 256
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Mon Dec 31 17:17:27 2018
//
package main

import "fmt"

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func main() {
	var N int
	fmt.Scan(&N)
	upper := make([]int, N)
	lower := make([]int, N)

	for i := range upper {
		fmt.Scan(&upper[i])
	}
	for i := range lower {
		fmt.Scan(&lower[i])
	}

	for i := range upper {
		if i+1 < len(upper) {
			upper[i+1] += upper[i]
		}
		if i+1 < len(lower) {
			lower[i+1] += lower[i]
		}
	}

	ans := 0
	for k := 0; k < len(upper); k++ {
		d := 0
		if k > 0 {
			d = lower[k-1]
		}
		ans = max(ans, upper[k]+lower[len(lower)-1]-d)
	}

	fmt.Println(ans)
}


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

using namespace std;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)
typedef long long ll;
typedef pair <int, int> P;
const int  INF = 2147483647;
const ll INFL = 9223372036854775807;
const ll mod = 1000000007;

using namespace std;


int main() {
	ll n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;

	bool e = false;
	REP(i, n-1) {
		int j = n - 1 - i;
		if (c*i - d * j <= a - b && a - b <= d * i - c * j)e = true;
	}
	if (e)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>

int main() {
    int n,t,x,y;
    scanf("%d", &n);
    int tnow = 0, xnow = 0, ynow = 0, dist;
    bool flg = true;
    for (int i = 1; i <= n; i++) {
        scanf("%d%d%d", &t, &x, &y);
        if (!flg) continue;
        dist = abs(x - xnow) + abs(y - ynow);
        if (!(t - tnow >= dist && ((t - tnow - dist) % 2 ==0))) {
            flg = false;
        }
    }
    printf(flg?"Yes\n":"No\n");
    return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {

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

        int n = sc.nextInt();
        int ans = 0;

        for (int i = 0; i < n; i++) {
            int num = sc.nextInt();
            while (num % 2 == 0) {
                ans++;
                num /= 2;
            }
        }

        System.out.println(ans);

        sc.close();

    }

}

Measured memory_bytes: 47740
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var AB = ReadSplitInt();
            Println(Max(Max(AB[0] + AB[1], AB[0] - AB[1]), AB[0] * AB[1]));
        }

        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static void YESOrNO(bool e) => Println(e ? "YES" : "NO");

        static void YesOrNo(bool e) => Println(e ? "Yes" : "No");

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


Measured memory_bytes: 13268
N=int(input())
A=list(map(int, input().split()))

#3 5 -1 
#3 2 6 1 
dis=[0]*(N+1)
for i in range(N+1):
    if i==N:
        #print("ok", i)
        dis[i]=abs(0-A[i-1])
    elif i==0:
        dis[i]=abs(A[0]-0)
    else:
        #print(i)
        dis[i]=abs(A[i]-A[i-1])
SUM=sum(dis)
A=A+[0]
for i in range(N):
    ans=SUM-dis[i+1]-dis[i]+(abs(A[i-1]-A[i+1]))
    print(ans)


Measured memory_bytes: 14172
/*
    Problem 97
    https://atcoder.jp/contests/abc150/tasks/abc150_d
*/
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
ll cntDiv2(ll a) {
    ll b = a;
    ll ret = 0;
    for (; b%2== 0; b/=2, ret++) {}
    return ret;
}
ll gcd(ll x, ll y) {return (y ? gcd(y, x%y) : x);}
/* main */
int main(){
    int N, M;
    cin >> N >> M;
    set<ll> A;
    for (int i = 0; i < N; i++) {
        ll a; cin >> a;
        A.insert(a/2);
    }
    set<ll> B;
    for (ll a : A) { B.insert(cntDiv2(a)); }
    if (B.size() > 1) {
        cout << 0 << '\n';
        return 0;
    }
    ll lcm = 1;
    for (ll a : A) {lcm = lcm / gcd(lcm, a) * a;}
    ll ans = (M / lcm + 1) / 2;
    cout << ans << '\n';
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

ll pow_ll(ll a, ll n){
    ll res = 1;
    REP(i,n) res *= a;
    return res;
}

ll C(ll n){
    return n*(n-1)/2;
}

int main(void){
    string N; cin >> N;
    int K; cin >> K;

    ll ans = 1;
    
    if(K == 1){
        ans = (ll)(N[0] - '0');
        ans += 9*(N.size()-1);
    }
    else if(K == 2){
        ans = 0;
        int pos = 1;
        while(pos < N.size() && N[pos] == '0') pos++;
        if(pos < N.size()){
            ans += (ll)(N[pos]-'0');
            ans += 9*(N.size()-pos-1);
        }
        ans += (ll)(N[0]-'0'-1)*9*(N.size()-1);

        FOR(i,2,N.size()){
            ans += 9*9*(i-1);
        }
    }
    else if(K == 3){
        ans = 0;
        int pos = 1;
        while(pos < N.size()-1 && N[pos] == '0') pos++;
        int pos2 = pos+1;
        while(pos2 < N.size() && N[pos2] == '0') pos2++;
        if(pos < N.size()-1){
            if(pos2 < N.size()){
                ans += (N[pos2]-'0');
                ans += 9*(N.size()-pos2-1);
            }
            //ans += (N[pos+1]-'0') + 9*(N.size()-pos-2);
            ans += (N[pos]-'0'-1)*9*(N.size()-pos-1);
            ans += 81*C(N.size()-pos-1);
        }
        ans += (ll)(N[0]-'0'-1)*81*C(N.size()-1);
        FOR(i,3,N.size()){
            ans += 9*81*C(i-1);
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
s=input()
s1 = int(s[:2])
s2 = int(s[2:])
m=[]
if 1 <= s1 and s1 <= 12:
    m.append(1)
if 1 <= s2 and s2 <= 12:
    m.append(2)
if len(m) == 2:
    print("AMBIGUOUS")
elif len(m) == 1:
    if m[0] == 1:
        print("MMYY")
    else:
        print("YYMM")
else:
    print("NA")


Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>
using namespace std;
#define INF 1e9

int v, m;
int D[21][21];

void warshall_floyd(){
	for(int k = 1; k <= v; k++){
		for(int i = 1; i <= v; i++){
			for(int j = 1; j <= v; j++){
				D[i][j] = min(D[i][j], D[i][k] + D[k][j]);
			}
		}
	}
}

int main(void){
	int x1, x2, y1, y2;
	int mon;
	scanf("%d\n%d", &v, &m);

	for(int i = 1; i <= v; i++){
		for(int j = 1; j <= v; j++){
			if(i == j)	continue;
			D[i][j] = INF;
		}
	}

	for(int i = 0; i < m; i++){
		int a, b, c, d;
		scanf("%d,%d,%d,%d", &a, &b, &c, &d);
		D[a][b] = c;
		D[b][a] = d;
	}

	scanf("%d,%d,%d,%d", &x1, &x2, &y1, &y2);
	
	mon = y1 - y2;
	warshall_floyd();
	mon -= D[x1][x2] + D[x2][x1];
	printf("%d\n", mon);
  return 0;
}

Measured memory_bytes: 1028
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.Vector as V

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    d <- getInt
    cs <- VU.fromList <$> getIntList
    ss <- V.fromList . map VU.fromList <$> replicateM d getIntList
    ts <- VU.fromList . map pred <$> replicateM d getInt
    let result = VU.create $ do
             sat <- VUM.replicate (d+1) (0 :: Int)
             ld <- VUM.replicate 26 (0 :: Int)
             decs <- VUM.replicate 26 (0 :: Int)
             forM_ [1..d] $ \day -> do
                 let contest = ts VU.! (day - 1)
                 let inc = ss V.! (day - 1) VU.! contest
                 VUM.write ld contest day
                 forM_ [0..25] $ \con -> do
                     let dec = cs VU.! con
                     lday <- VUM.read ld con
                     VUM.write decs con $ dec * (day - lday)
                 s <- VUM.read sat (day - 1)
                 VUM.write sat day (s + inc)
                 forM_ [0..25] $ \con -> do
                     dec <- VUM.read decs con
                     VUM.modify sat (subtract dec) day
             return sat
    VU.mapM_ print $ VU.tail result

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

int main() {
    long n, a, b, c;
    cin >> n >> a >> b >> c;
    string t, u;
    for(int i = 0; i < n; i++) {
        string s;
        cin >> s;
        t += s == "AB" ? 'C' : s == "AC" ? 'B' : 'A';
    }
    for(int i = 0; i < n; i++) {
        switch(t[i]) {
        case 'A':
            if(!c || b && i + 1 < n && t[i + 1] == 'B')
                b--, c++, u += 'C';
            else
                b++, c--, u += 'B';
            break;
        case 'B':
            if(!c || a && i + 1 < n && t[i + 1] == 'A')
                a--, c++, u += 'C';
            else
                a++, c--, u += 'A';
            break;
        default:
            if(!b || a && i + 1 < n && t[i + 1] == 'A')
                a--, b++, u += 'B';
            else
                a++, b--, u += 'A';
        }
        if(a < 0 || b < 0 || c < 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes\n";
    for(auto y : u)
        cout << y << '\n';
    return 0;
}


Measured memory_bytes: 3700
#import <Foundation/Foundation.h>
int main(){
    @autoreleasepool {
        int N;
        char C[102] = {'\0'};
        scanf("%d %s",&N,C);
        NSMutableString *s = [NSMutableString string];
        int v=0;
        for(int i=N-1;i>=0;i--){
            char c = C[i];
            if(c=='('){
                v--;
                if(v<0){
                    [s appendString:@")"];
                    v++;
                }
            } else {
                v++;
            }
            [s insertString:[NSString stringWithFormat:@"%c", c] atIndex:0];
        }
        for(int j=0;j<v;j++){
            [s insertString:@"(" atIndex:0];
        }
        puts(s.UTF8String);
    }
}


Measured memory_bytes: 9120
/* Author rumoisen */
/* created 2018/10/07 */

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
 
using namespace std;
 
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

void no(){cout<<"No"<<endl;exit(0);}
void yes(){cout<<"Yes"<<endl;exit(0);}
void No(){cout<<"NO"<<endl;exit(0);}
void Yes(){cout<<"YES"<<endl;exit(0);}

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

using namespace std;

int ketanowa(int n)
{
    int s=0;
    while(n>0){
        s+=n%10;
        n/=10;
    }
    return s;
}
int main()
{
    int n,m;
    cin>>n>>m;
    cout<<(n-1)*(m-1)<<endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
def calc(n):
  dic={}
  f=2
  while f*f<=n:
    if n%f==0:
      if f in dic:
        dic[f]+=1
      else:
        dic[f]=1
      n//=f
    else:
      f+=1
  if n!=1:
    if n in dic:
      dic[n]+=1
    else:
      dic[n]=1
  return dic

def ans_count(dic):
  ans=0
  for val in dic.values():
    k=1
    while k*(3+k)//2<val:
      k+=1
    ans+=k
  return ans

print(ans_count(calc(n)))

Measured memory_bytes: 9140
package main

import (
	"fmt"
//	"sort"
//	"math"
//	"regexp"
)

var N,K,ans int
func main(){
	fmt.Scan(&N,&K)

	x := make([]int,N)
	for i:=0;i<N;i++{
		fmt.Scan(&x[i])
	}

	for i:=0;i<N;i++{
		if x[i] < K-x[i]{
			ans += x[i]
		}else{
			ans += K-x[i]
		}
	}
	fmt.Println(ans*2)
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<cstdio>

using namespace std;

char S[300005];

int main()
{
	int N, ans = 0, check = 0;
	char c;


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

	int mark = 0;
	for (int j = 1; j < N; j++) {
		if (S[j] == 'E') mark++;
	}
	ans = mark;
	check = mark;
	for (int i = 1; i < N; i++) {
		if (S[i - 1] == 'W') check++;
		if (S[i] == 'E') check--;
		ans = min(ans, check);
	}

	cout << ans;

	char qq;
	cin >> qq;
	return 0;
}


Measured memory_bytes: 512
object Main{

  var h:Int = 0
  var w:Int = 0

  def isValid(x:Int,y:Int):Boolean = {
    if( x < 0 || x >= this.w || y < 0 || y >= this.h) false
    else true
  }

  def dfs(x:Int,y:Int,cs: Array[Array[Int]]):Int = {
    val dxy = Array(1,0,-1)
    val ans = cs(y)(x)
    cs(y)(x) = 0

    for(i<-0 until 3){
      for(j<-0 until 3){
        if( isValid(x+dxy(j),y+dxy(i)) ){
          if(cs(y+dxy(i))(x+dxy(j)) == 1){
            dfs(x+dxy(j),y+dxy(i),cs)
          }
        }
      }
    }

    return ans
  }

  def main(args: Array[String]):Unit = {
    var wh = readLine.split(" ").map(n => n.toInt)
    while(wh(0)!=0 && wh(1)!=0){
      this.w = wh(0)
      this.h = wh(1)
      val cs = Array.ofDim[Int](h,w)
      for( i<- 0 until h){
        cs(i) = readLine.split(" ").map(n => n.toInt)
      }

      var ans = 0
      for( y<-0 until h){
        for( x<-0 until w){
          if(cs(y)(x)==1)
            ans += dfs(x,y,cs)

        }
      }
      println(ans)
      wh = readLine.split(" ").map(n => n.toInt)
    }
  }

}
  

Measured memory_bytes: 57056
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lpin(a,i,n) for(int i=0;i<n;i++){cin>>a[i];}
int dp[25000][300];
int  main(){
  while(1){
    int n,m;
    cin>>n>>m;
    int c[20],x[25000];
    if(n==0&& m==0) break;
    lp(i,25000){
      lp(j,300){
	dp[i][j]=-1;
      }
    }
    lpin(c,i,m);
    lpin(x,i,n);
    dp[0][128]=0;
    for(int i=1;i<=n;i++){
      lp(j,256){
	if(dp[i-1][j]!=-1){
	  lp(k,m){
	    if(dp[i][max(min(j+c[k],255),0)]==-1){
	      dp[i][max(min(j+c[k],255),0)]=dp[i-1][j]+(max(min(j+c[k],255),0)-x[i-1])*(max(min(j+c[k],255),0)-x[i-1]);
	    }
	    else
	    dp[i][max(min(j+c[k],255),0)]=min(dp[i-1][j]+(max(min(j+c[k],255),0)-x[i-1])*(max(min(j+c[k],255),0)-x[i-1]),dp[i][max(min(j+c[k],255),0)]);
	  }
	}
      }
    }
    int ans=-1;
    lp(i,300){
      if(dp[n][i]!=-1){
	if(ans==-1)
	  ans=dp[n][i];
	else ans=min(ans,dp[n][i]);
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 32468
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney,chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun


#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

int ctoi(char c) {
	switch (c)
	{
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default:
		cout << "ERR_ctoi" << endl;
		return -1;
	}
}
int main() {
	int n;
	cin >> n;
	if (n < 1200) {
		PRI("ABC");
	}
	else if (n < 2800) {
		PRI("ARC");
	}
	else PRI("AGC");
	return 0;
}

Measured memory_bytes: 3616
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)
    
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b;
    cin>>a>>b;
    ll ans = 0;
    while(a!=0){
        a/=b;
        ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
const int N=100005;
int main(){
	int n,a[N],b[N];
	long long ans;
	scanf("%d",&n);
	for(int i=0;i<=n;++i) scanf("%d",&a[i]);
	for(int i=0;i<n;++i) scanf("%d",&b[i]);
	ans=0;
	for(int i=0;i<n;++i){
		if(a[i]>b[i]){
			ans+=b[i];
			a[i]-=b[i];
			b[i]=0;
		}
		else{
			if(a[i]<=b[i]){
				ans+=a[i];
				b[i]-=a[i];
				a[i]=0;
			}
			if(a[i+1]>b[i]){
				ans+=b[i];
				a[i+1]-=b[i];
				b[i]=0;
			}
			else{
				ans+=a[i+1];
				b[i]-=a[i+1];
				a[i+1]=0;
			}
			
		}
		
		
	}
		
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
	int n;
	cin >> n;
	int a[n];
	int pn = 0;

	for (int i = 0; i < n; i++) cin >> a[i];

	for (int i = 0; i < n; i++){
		bool flag = true;
		for (int j = 2; j < n; j++){
			if (a[i] % j == 0 && a[i] != j){
				flag = false;
				break;
			}
		}
		if (flag) pn++;
	}

	cout << pn << endl;

	return 0;
}

Measured memory_bytes: 1196
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            String S = in.next();
            String T = in.next();
            if (T.substring(0, T.length() - 1).equals(S)) {
                out.println("Yes");
            } else {
                out.println("No");
            }
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    return null;
                }
            }
            return st.nextToken();
        }

    }
}



Measured memory_bytes: 32896
n, m=map(int, input().split())
a=list(map(int, input().split()))
a.sort()
aa=a[:]
for i in range(n-2, -1, -1):
  aa[i]+=aa[i+1]

g=[0]*(a[-1]+1)
for i in range(n):
  g[a[i]]+=1
for i in range(a[-1]-1, -1, -1):
  g[i]+=g[i+1]
  
def f(index, point):
  tmp=point-a[index]
  if tmp>a[-1]:
    return 0
  elif tmp<=0:
    return n
  else:
    return g[tmp]
  
def ff(point):
  return sum([f(i, point) for i in range(n)])

def fff():
  x=0
  y=2*a[-1]+1
  c=(x+y)//2
  while y-x>1:
    if ff(c)>m:
      x=(x+y)//2
    else:
      y=(x+y)//2
    c=(x+y)//2
  return y

def ffff(index, point):
  tmp=f(index, point)
  if tmp>0:
    return aa[-tmp]+a[index]*tmp
  else:
    return 0
  
p=fff()
q=m-ff(p)
out=0
for i in range(n):
  out+=ffff(i, p)
out+=(p-1)*q
print(out)

Measured memory_bytes: 17384
#include<cstdio>
#include<algorithm>
#include<set>
#include<queue>
using namespace std;
#define pii pair<int,int>
int n, A[201000], B[201000];
priority_queue<pii>PQ;
int main() {
	int i;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &A[i]);
	}
	for (i = 0; i < n; i++) {
		scanf("%d", &B[i]);
		PQ.push({ B[i],i });
	}
	long long res = 0;
	while (!PQ.empty()) {
		pii it = PQ.top();
		PQ.pop();
		int pv = it.second;
		if (B[pv] <= A[pv]) {
			continue;
		}
		long long aa = B[(pv + n - 1) % n];
		long long bb = A[pv];
		long long cc = B[(pv + 1) % n];
		if (B[pv] < aa + bb + cc) {
			puts("-1");
			return 0;
		}
		long long z = (B[pv] - bb) / (aa + cc);
		res += z;
		B[pv] -= z*(aa + cc);
		if (A[pv] != B[pv]) {
			PQ.push({ B[pv],pv });
		}
	}
	for (i = 0; i < n; i++) {
		if (A[i] != B[i]) {
			puts("-1");
			return 0;
		}
	}
	printf("%lld\n", res);
}

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

int main(void){
    int w = 0, a = 0, b = 0; 
//    int cent_a = 0, cent_b = 0;

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

//    cent_a = a + w / 2;
//    cent_b = b + w / 2;


    if(a > b){
        int tmp = 0;
        tmp = a;
        a = b;
        b = tmp;
    }

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

} 


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <map>
#include <vector>

using namespace std;

int main()
{
	int n = 0;
	int s[100] = { 0 };
	int score = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> s[i];
	}

	for (int j = 0; j < n; j++)
	{
		score += s[j];
	}

	int min = 0;
	bool first_flag = 0;

	//成績が10の倍数の場合
	if (score % 10 == 0)
	{
		for (int k = 0; k < n; k++)
		{
			
				if (s[k] % 10 != 0)
				{
					if (first_flag==0)
					{
						min = s[k];
						first_flag = 1;
					}
					else
					{
						if (s[k] < min)
						{
							min = s[k];
						}
					}
				}
		}
		
	}
	else
	{
		cout << score << endl;
		return 0;
	}

	//10で割り切れない整数が存在する場合
	if (min != 0)
	{
		score -= min;
		cout << score << endl;
		return 0;
	}
	else
	{
		score = 0;
		cout << score << endl;

	}
	
	return 0;
}

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

//最大公約数を求める関数 O(logb)
int64_t gcd(int64_t a, int64_t b){
    return b ? gcd(b, a % b) : a;
}

int main(){
    int n;
    cin >> n;
    int ans = 0;
    for(int i=1; i<=n; i++){
        for(int j=1; j<=n; j++){
            for(int k=1; k<=n; k++){
                ans += gcd(i, gcd(j, k));
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main (string[] args)
        {
            string[] str;
            str = Console.ReadLine ().Split (' ');

            double r = double.Parse (str[0]);
            double pi = 3.14159265358979;

            double S = pi * r * r;
            double L = 2 * pi * r;

            Console.WriteLine ("{0:0.######} {1:0.######}", S, L);
        }
    }

    class MyLibrary
    {

        // 自作の関数
        public static int MyFunction (int n)
        {
            return 0;
        }
    }
}


Measured memory_bytes: 17944
#include<bits/stdc++.h> 
using namespace std;
#define se second
#define fr first
#define int long long int
#define pb push_back
#define inf 1e18
#define all(v) v.begin(),v.end()
#define CHAL_BAAP_KO_MT_SIKHA ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
/*
    Damn Fast:TheFuckinMastermind
    while(How to solve the Question?){
                Read the Question Again!!
           }
        do
            Practise
    #Motivation::::0/0  
*/
const int N=2e3;
int dp[N+1][N+1];
char a[N+1][N+1];
int solve(int i,int j){
    if(i<=0 or j<=0)
        return 0;
    if(i==1 and j==1)
        return 1;
    if(dp[i][j]!=-1)
        return dp[i][j];
    int ans=0;
    if(a[i-1][j]=='.'){
        ans+=solve(i-1,j);
        ans%=mod;
    }
    if(a[i][j-1]=='.'){
        ans+=solve(i,j-1);
        ans%=mod;
    }
    return dp[i][j]=ans;
}
signed main()
{
   
    CHAL_BAAP_KO_MT_SIKHA
    int h,w;
    cin>>h>>w;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin>>a[i][j];
        }
    }
    memset(dp,-1,sizeof(dp));
    cout<<solve(h,w);
}

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

#define int long long 
#define put(n) cout<<(n)<<"\n"
#define FOR(i,num,N) for(int(i)=(num);(i)<(N);(i)++)
#define RFOR(i,num,N) for(int (i)=(num);(i)>(N);(i)--)
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()

signed main(){
    int N;
    cin>>N;
    map<int,int> mp;
    int a;
    FOR(i,0,N){
        cin>>a;
        mp[a]++;
    }
    int ans = 0;
    int count = 0;
    for(auto itr = mp.rbegin(); itr != mp.rend();++itr){
        if(itr->second >= 4 && ans == 0){
            ans = itr->first*itr->first;
            break;
        }
        else if(itr->second >=2 && count < 2){
            if(count == 0) ans = 1;
            ans *= itr->first;
            ++count;
        } 
    }
    put(ans);
}


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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    string S;
    cin >> S;
    reverse(S.begin(), S.end());
    const size_t N = S.size();
    vector<int> v_2019(N, 0);
    vector<ll> dp(2019, 0);
    int n_base = 1;
    for(int i=0; i<N; i++){
        v_2019[i] = ((S[i]-'0') * n_base)% 2019;
        n_base *= 10;
        n_base %= 2019;
    }
    for(int i=1; i<N; i++){
        v_2019[i] += v_2019[i-1];
        v_2019[i] %= 2019;
    }
    map<ll, ll> vmap;
    vmap[0] = 1;
    for(auto v : v_2019){
        if(vmap.count(v)==0) vmap[v] = 0;
        vmap[v]++;
    }
    ll res = 0;
    for(auto m : vmap){
        res += m.second * (m.second - 1) / 2;
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 4328
#include<cstdio>
#include<algorithm>
#include<vector>
typedef std::pair<long long,int> pli;
int main(){
  std::vector<pli> v;
  int n,m;
  scanf("%d%d",&n,&m);
  for(int i=0;i<n;i++){
    long long a;
    int b;
    scanf("%lld%d",&a,&b);
    v.push_back({a,b});
  }
  std::sort(v.begin(),v.end());
  long long ans=0;
  int itr=0;
  while(m>0){
    pli p=v[itr];
    if(m<p.second){
      ans+=p.first*m;
      m=0;
    }else{
      ans+=p.first*p.second;
      m-=p.second;
    }
    itr++;
  }
  printf("%lld",ans);
  return 0;
}


Measured memory_bytes: 2420
#include <cctype>
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
int main()
{
string str;
getline(cin,str);
for(int i=0;i<=str.length()-1;i++)
{if(isupper(str[i]))
{str[i] = str[i] + 32;}
else if(islower(str[i]))
{str[i] = str[i] - 32;}
}
cout << str << endl;
}


Measured memory_bytes: 3200
#include <stdio.h>
#include <ctype.h>
#include <string.h>

int main(void){
    char W[11],T[1000];
    int i,count=0;
    
    scanf("%s",W);
    while(scanf("%s",T),strcmp(T,"END_OF_TEXT")){
        for(i=0;T[i]!='\0';i++){
            T[i]=tolower(T[i]);
        }
        
        if(strcmp(W,T)==0) count+=1;
    }
    
    printf("%d\n",count);
    
    return 0;
}


Measured memory_bytes: 2104
#include <algorithm>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.endl(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 998244353  // prime;
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  // cout << fixed << setprecision(15);
}
// int size = 200001;  // e6 + 1
vector<ll> fac;   // n!(mod M)
vector<ll> ifac;  // k!^{M-2} (mod M)
vector<ll> inv;   // k!^{M-2} (mod M)
////////////////////////////////////////////////
void fac_mod(int size) {
  // fac[i] = i! (mod M)
  fac.resize(size);
  fac[0] = 1;
  fac[1] = 1;
  int n = fac.size();
  for (int i = 0; i < n - 1; i++) {
    fac[i + 1] = fac[i] * (i + 1) % MOD;
  }
}
////////////////////////////////////////////////
void ifac_mod(int size) {
  // ifac[i] = 1/i! (mod M)
  ifac.resize(size);
  inv.resize(size);
  ifac[0] = 1;
  ifac[1] = 1;
  inv[1] = 1;
  int n = ifac.size();
  for (int i = 2; i < n - 1; i++) {
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    ifac[i] = ifac[i - 1] * inv[i] % MOD;
  }
}
////////////////////////////////////////////////
void nCk_init(int m) {
  if (m <= 0) {
    cout << "error! invalid m val: m = " << m << endl;
  }
  fac_mod(m + 1);
  ifac_mod(m + 1);
}
////////////////////////////////////////////////
ll nCk_mod(int n, int k) {
  // nCk (mod M)
  if (n == 0 && k == 0) return 1;
  if (n < k || k < 0) return 0;
  return fac[n] * (ifac[n - k] * ifac[k] % MOD) % MOD;
}
////////////////////////////////////////////////
ll pow_mod(ll x, int n) {
  // x^n (mod M)
  ll pow = 1;
  while (n != 0) {
    if (n & 1) pow = pow * x % MOD;
    x = x * x % MOD;
    n = n >> 1;
  }
  return pow;
}
////////////////////////////////////////////////
int main() {
  init();
  ll n, m, k;
  cin >> n >> m >> k;
  nCk_init(n);
  vector<ll> mpow(n, 0);
  vector<ll> ncj(n, 0);
  REP(i, n) {
    mpow[i] = pow_mod((ll)(m - 1), i);
    ncj[i] = nCk_mod((n - 1), i);
  }
  ll ans = 0;
  REP(i, k + 1) {
    // cout << mpow[n - 1 - i] << " " << ncj[i] << " "
    //  << ((m * mpow[n - 1 - i]) % MOD * ncj[i]) % MOD << endl;
    ans += ((m * mpow[n - 1 - i]) % MOD * ncj[i]) % MOD;
    ans %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 11068
#include <iostream>
#include <vector>
#include <cstring>
#include<cmath>

#define LL long long
using namespace std;
#define MAXN 60
#define MAXA 60

int N, M, S;

struct e
{
    int u, v, a, b;
};
vector<e> edge;
int C[MAXN], D[MAXN];
LL dp[MAXN][MAXA * MAXN];
LL ans;

int main()
{
    scanf("%d%d%d", &N, &M, &S);
    int u, v, a, b;
    for (int i = 1; i <= M; i++)
    {
        scanf("%d%d%d%d", &u, &v, &a, &b);
        edge.push_back({u, v, a, b});
        edge.push_back({v, u, a, b});
    }
    for (int i = 1; i <= N; i++)
    {
        scanf("%d%d", &C[i], &D[i]);
    }

    memset(dp, 0x3f, sizeof(dp));
    if (S > 2500)
        S = 2500;
    dp[1][S] = 0;
    while (true)
    {
        bool update = false;

        for (int i = 0; i < edge.size(); i++)
        {
            int u = edge[i].u;
            int v = edge[i].v;
            int a = edge[i].a;
            int b = edge[i].b;
            for (int j = 0; j <= 2500; j++)
            {
                if (j >= C[v])
                {
                    if (dp[v][j] > dp[v][j - C[v]] + D[v])
                    {
                        update = true;
                        dp[v][j] = dp[v][j - C[v]] + D[v];
                    }
                }
                if (dp[v][j] > dp[u][j + a] + b)
                {
                    update = true;
                    dp[v][j] = dp[u][j + a] + b;
                }
            }
        }

        if (!update)
            break;
    }

    for (int i = 2; i <= N; i++)
    {
        LL ans = 1e18;
        for (int j = 0; j <= 2500; j++)
        {
            if (dp[i][j] < ans)
            {
                ans = dp[i][j];
            }
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 5424
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#define loop(n) for (int i = 0; i < n; i++)
#define INT_MAX 2147483647
#define LLINT_MAX 9223372036854775807
#define mod 1000000007
#define ll long long int
using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int cnt = 0;
	loop(100)
		if (a <= i&&i < b&&c <= i&&i < d)cnt++;
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a, b, c, d, N, ans=0, L, X;
    vector<int> v(3);
    char tmp, tmp2;
    string S, S2, S3;
    bool flag=true;
    
    cin >> a >> b;
    tmp = b-a;
    // ans = a<=b ? a:a-1;

    if(tmp %2==1)
	puts("IMPOSSIBLE");
    else{
	for(int i=0; ;i++){
	    if(abs(a-i) == abs(b-i)){
		cout << i << endl;
		break;
	    }
		
	}
	

    }

    // if(S[1]==S[2] &&(S[0]==S[1] | S[2]==S[3]))
    // 	cout << "Yes" <<endl;
    // else
    // 	cout << "No" <<endl;

    // string S;
    // cin >>S;
    // // cout << S + "pp"<<endl;
    // if(flag)
    // 	puts("Yes");
    // else
    // 	puts("No");
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
const int MAX = 1000000;
const int MOD = 1000000007;

int main(){
	int a,b;
	string s,t,u;
	cin>>s>>t>>a>>b>>u;
	if(s==u) a--;
	else b--;
	OUT(a);
	OUT(b);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	int N;
	string S;

	cin >> N >> S;
	int ma = -1;
	for(int i = 0; i < N; i++) {
		int alf[30] = {};
		for(int j = 0; j < i; j++) {
			alf[S[j] - 'a']++;
		}
		int tmp = 0;
		for(int j = i; j < N; j++) {
			if(alf[S[j] - 'a'] > 0) {
				alf[S[j] - 'a'] = 0;
				tmp++;
			}
		}
		ma = max(ma, tmp);
	}
	cout << ma << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,M;cin>>N>>M;
  vll A(N),B(N);
  vector<pair<ll,int> > C(N);
  vll Bsum(N);
  vll Q(N);
  repeat(i,N){
    cin>>A[i]>>B[i];
    C[i]={max(A[i]-B[i],0ll),i};
    Bsum[i]=B[i];
  }
  sort(C.begin(),C.end());
  vector<vint> g(N);
  repeat(i,M){
    int u,v;cin>>u>>v;u--;v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  vector<bool> used(N,false);
  UnionFind uf(N);
  repeat(i,N){
    int v = C[i].second;
    used[v]=true;
    set<int> V;
    for(int u:g[v])if(used[u])V.insert(uf.root(u));
    ll Bsumsum=Bsum[v];
    for(int u:V)Bsumsum += Bsum[u];
    Q[v]=Bsumsum+C[i].first;
    for(int u:V){
      Q[v]=min(Q[v],max(Q[u],C[i].first)+Bsumsum-Bsum[u]);
      uf.unionSet(v,u);
    }
    Q[uf.root(v)]=Q[v];
    Bsum[uf.root(v)]=Bsumsum;
  }
  cout << Q[uf.root(0)] << endl;
  return 0;
}


Measured memory_bytes: 12540
#include <bits/stdc++.h>
using namespace std;
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; }
  
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    int N; cin >> N;
    vector<int> a(N+2,10000000);
    for(int i=1; i<=N; i++) cin >> a[i];
    int ans = 0;

    for(int left=1; left<=N; left++){
        if(a[left] == left){
            int right = left+1;
            while(a[right] == right) right++;
            ans += max(1,(right-left+1)/2);
            left = right-1;
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)


int dy[] = {1, 1, 0, -1, -1, -1, 0, 1, 0};
int dx[] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
int x[100010], y[100010];
int main(void){
	int h, w, n; cin >> h >> w >> n;
	set<pair<int, int> > s;
	set<pair<int, int> > used;
	rep(i, n){
		int a, b; cin >> a >> b;
		a--; b--;
		y[i] = a; x[i] = b;
		s.insert(make_pair(a, b));//y,x
	}

	ll ans[10];
	rep(i, 10) ans[i] = 0;

	rep(i, n){
		rep(j, 9){
			int cy = y[i] + dy[j], cx = x[i] + dx[j];//周りを調べる
			if(!(0 <= cy && cy < h && 0 <= cx && cx < w)) continue;
			if(used.count(make_pair(cy, cx)) == 1)continue;//すでに調べた
			// printf("%d %d\n", cy, cx);
			int tmp = 0;
			rep(k, 9){

				int ny = cy + dy[k], nx = cx + dx[k];
				if(!(0 <= ny && ny < h && 0 <= nx && nx < w)) break;
				if(s.count(make_pair(ny, nx)) == 1)tmp++;
				if(k == 8){
					// printf("%d %d %d\n", cy, cx, tmp);
					used.insert(make_pair(cy, cx));
					ans[tmp]++;
				}
			}
		}		
	}
	ll sum = 0;
	rep(i, 10){
		sum += ans[i];
	}
	printf("%lld\n", ((ll)h - 2) * ((ll)w - 2) - sum);
	for (int i = 1; i <= 9; ++i){
		printf("%lld\n", ans[i]);
	}
	return 0;
}

Measured memory_bytes: 47872
N=int(input())
A=[int(i) for i in input().split()]
arr={}
P={}
for a in A:
	if a in arr:
		arr[a]+=1
	else:
		arr[a]=1
for k,v in arr.items():
	P[k]=k*v
S=sum([i for i in P.values()])
Q=int(input())
for q in range(Q):
	B,C=[int(i) for i in input().split()]
	if B in arr:
		if C in arr:
			arr[C]+=arr[B]
			P[C]+=arr[B]*C
		else:
			arr[C]=arr[B]
			P[C]=arr[B]*C
		S-=P[B]
		S+=arr[B]*C
		del arr[B]
		del P[B]
	print(S)


Measured memory_bytes: 24960
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 998_244_353, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "p", long, "dist");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    auto n = lread!ulong();
    auto d = aryread!ulong();
    auto count = new ulong[](n - 1);
    auto dist = new ulong[](n - 1);
    foreach (e; d)
        count[e]++;
    if (d[0] != 0 || count[0] > 1)
    {
        writeln(0);
        return;
    }
    dist[0] = 1;
    foreach (i; iota(1, n - 1))
    {
        dist[i] = dist[i - 1] * powmod(count[i - 1], count[i], MOD);
        dist[i] %= MOD;
    }
    // dist.writeln();
    dist[$ - 1].writeln();
}

auto powmod(ulong x, ulong n, ulong m)
{
    ulong ret = 1;
    while(n > 0)
    {
        ret *= x;
        ret %= m;
        n--;
    }
    return ret % m;
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 4356
L=[list(map(int,input().split())) for _ in range(3)]
N=int(input())
B=[int(input()) for _ in range(N)]
for i in B:
  for j in range(3):
    for k in range(3):
      if i==L[j][k]:
        L[j][k]=0
T=False
for i in range(3):
  if L[i][0]==L[i][1]==L[i][2]:
    T=True
  elif L[0][i]==L[1][i]==L[2][i]:
    T=True
if L[0][0]==L[1][1]==L[2][2] or L[0][2]==L[1][1]==L[2][0]:
  T=True
if T==True:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9144