akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <complex>
#include <stdio.h>
#include <unordered_set>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VCH;
typedef vector<LD> VLD;
typedef vector<string> VS;
typedef vector<VS> VSS;
typedef vector<VI> VVI;
typedef vector<VLL> VVLL;
typedef vector<VCH> VVCH;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDD> VPDD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define next fake_next
#define prev fake_prev
#define left fake_left
#define right fake_right

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())

const LD PI = acos(-1.0);
const LL mod = 1000000007;
const LL INF = 2e9 + 1;
const LL LINF = 1e12;
const LL MAXN = 5e3 + 1;
const LD EPS = 1e-6;

void bad()
{
	cout << "No";
	exit(0);
}

void ok()
{
	cout << "Yes";
	exit(0);
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("In.txt", "w", stdout);

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

	VVCH a(h, VCH(w));
	FOR(i, 0, h)
		FOR(j, 0, w)
		cin >> a[i][j];

	VI cnt(26, 0);
	FOR(i, 0, h)
		FOR(j, 0, w)
		cnt[a[i][j] - 'a']++;

	if ((h % 2 == 0) && (w % 2 == 0))
	{
		FOR(i, 0, 26)
			if (cnt[i] % 4)
				bad();
		ok();
	}

	if ((h & 1) && (w & 1))
	{
		int x = 0;
		FOR(i, 0, 26)
			if (cnt[i] & 1)
				++x;

		if (x > 1)
			bad();

		FOR(i, 0, 26)
			if (cnt[i] & 1)
				--cnt[i];

		x = 0;
		FOR(i, 0, 26)
			if (cnt[i] % 4)
				++x;

		if (x > h/2 + w/2)
			bad();
		else
			ok();
	}

	if (h & 1)
		swap(h, w);

	FOR(i, 0, 26)
		if (cnt[i] & 1)
			bad();

	int x = 0;
	FOR(i, 0, 26)
		if (cnt[i] % 4)
			++x;

	if (x > h / 2)
		bad();
	else
		ok();

	return 0;
}

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

int main() {
  int n;
  string s;
  cin >> s;
  n = s.size();
  vector<int> ans(n);
  rep(ri,2) {
    { // solve R
      int cnt = 0;
      rep(i,n) {
        if (s[i] == 'R') cnt++;
        else {
          ans[i] += cnt/2;
          ans[i-1] += (cnt+1)/2;
          cnt = 0;
        }
      }
    }
 
    reverse(ans.begin(), ans.end());
    reverse(s.begin(), s.end());
    rep(i,n) {
      if (s[i] == 'L') s[i] = 'R';
      else s[i] = 'L';
    }
  }
 
  rep(i,n) {
    printf("%d\n", ans[i]);
  }
  return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <utility>
#include <string>
using namespace std;
#define INF 2000000000

class stack
{
  private:
    int stk[200];
    int ptr;

  public:
    stack()
    {
        for (int i = 0; i < 200; i++)
            stk[i] = INF;
        ptr = 0;
    }
    void push(int x)
    {
        stk[++ptr] = x;
    }
    int pop()
    {
        int r = stk[ptr];
        stk[ptr--] = INF;
        return r;
    }
};

int main(void)
{
    int a, b;
    char c[10] = "0";
    char *s = c;
    stack stk;
    while (scanf("%s", s)!=EOF)
    {
        //cout << s << "\n";
        if (s[0] == '+')
        {
            b = stk.pop();
            a = stk.pop();
            stk.push(a + b);
        }
        else if (s[0] == '-')
        {
            b = stk.pop();
            a = stk.pop();
            stk.push(a - b);
        }
        else if (s[0] == '*')
        {
            b = stk.pop();
            a = stk.pop();
            stk.push(a * b);
        }
        else if (s[0] == '/')
        {
            b = stk.pop();
            a = stk.pop();
            stk.push(a / b);
        }
        else
        {
            stk.push(atoi(s));
        }
    }

    printf("%d\n", stk.pop());

    return 0;
}



Measured memory_bytes: 3232
#include <stdio.h>

int main() {
  int n, m;
  int g = 0, k = 0;
  scanf("%d %d\n", &n, &m);

  for (int i = n - 1; i > 0; i--)
    g += i;
  for (int i = m - 1; i > 0; i--)
    k += i;
  
  printf("%d\n", g + k);
  return 0;
}

Measured memory_bytes: 128
#写経をもとに

ni = lambda: int(ns())
na = lambda: list(map(int, input().split()))
ns = lambda: input().rstrip() 

n, m = na()
ab = []
for i in range(n):
    ab.append(na())
ab.sort(key=lambda x: x[0])
 
rem = m
ans = 0
for v in ab:
    buy = min(rem, v[1])
    ans += buy * v[0]
    rem -= buy
print(ans)

Measured memory_bytes: 29020
S = input()
T = input()
def match(s,t):
    for c,d in zip(s,t):
        if c == "?":
            continue
        elif c == d:
            continue
        else:
            return False
    return True
for i in range(len(S)-len(T), -1, -1):
    s = S[i:i+len(T)]
    if match(s, T):
        print((S[:i]+T+S[i+len(T):]).replace("?","a"))
        exit(0)
print("UNRESTORABLE")

Measured memory_bytes: 9076
from sys import stdin
input = stdin.readline
mod = 998244353
from collections import defaultdict

def solve():
    n,K = map(int,input().split())
    step = [tuple(map(int,inp.split())) for inp in stdin.read().splitlines()]
    dp=defaultdict(int)

    f=0
    dp[1]=1
    for i in range(1,1+n):
        for r,l in step:
            f=(f+-dp[i-1-l]+dp[i-r])%mod
        dp[i]=(dp[i]+f)%mod
    print(dp[n])



if __name__ == '__main__':
    solve()


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

using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
	public Program() { }

	static void Main(string[] args)
	{
		new Program().prog();
	}
	Scanner cin;
	const int MOD = 1000000007;
	const int INF = int.MaxValue;
	const double EPS = 1e-7;
	const double PI = 3.1415926536;

	void prog()
	{
		cin = new Scanner();
		int[,] dir8 = new int[8, 2] { { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1 }, { 0, 1 }, { 1, -1 }, { 1, 0 }, { 1, 1 } };
		int[,] dir4 = new int[4, 2] { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };

		int H = cin.nextInt();
		int W = cin.nextInt();
		int A = cin.nextInt();
		int B = cin.nextInt();
		if (H == 1 || W == 1)
		{
			Console.WriteLine(0);
			return;
		}
		long ans = 0;
		int size = Math.Max(W - 2 + H - A, A - 1 + W - B - 1) + 1;
		long[] inv = new long[size];
		long[] fac = new long[size];
		long[] facInv = new long[size];
		ModInv(size - 1, inv, MOD);
		FacInv(size - 1, inv, fac, facInv, MOD);
		for (int i = 0; i < W - B; i++)
		{
			//Console.WriteLine(i);
			ans += CombiMod(W - 2 + H - A - i, H - A - 1, MOD, inv, fac, facInv) * CombiMod(i + A - 1, i, MOD, inv, fac, facInv);
			ans %= MOD;
		}
		Console.WriteLine(ans);
	}
	long CombiMod(int n, int k, int mod, long[] inv, long[] fac, long[] facInv)
	{
		if (n == 0 && k == 0) return 1;
		if (n <= 0 || k < 0 || k > n) return 0;
		if (k == 0) return 1;
		//Console.WriteLine("n:{0}, k:{1}", n, k);
		return (((fac[n] * facInv[k]) % mod) * facInv[n - k]) % mod;
	}

	// モジュラ逆数を求める(modが素数と仮定)
	void ModInv(int n, long[] inv, int mod)
	{
		inv[0] = 0;
		inv[1] = 1;
		for (int i = 2; i <= n; i++)
		{
			//Console.WriteLine(i);
			inv[i] = mod - ((mod / i) * inv[mod % i] % mod);
		}
	}

	// n!をmodで割った余り
	void FacInv(int n, long[] inv, long[] fac, long[] facInv, int mod)
	{
		fac[0] = facInv[0] = 1;
		for (int i = 1; i <= n; i++)
		{
			fac[i] = (fac[i - 1] * i) % mod;
			facInv[i] = (facInv[i - 1] * (int)inv[i]) % mod;
		}
	}
}

class Scanner
{
	string[] s;
	int i;

	char[] cs = new char[] { ' ' };

	public Scanner()
	{
		s = new string[0];
		i = 0;
	}

	public string next()
	{
		if (i < s.Length) return s[i++];
		string st = Console.ReadLine();
		while (st == "") st = Console.ReadLine();
		s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
		i = 0;
		return next();
	}

	public int nextInt()
	{
		return int.Parse(next());
	}

	public long nextLong()
	{
		return long.Parse(next());
	}

	public double nextDouble()
	{
		return double.Parse(next());
	}
}

Measured memory_bytes: 7128
let () = Scanf.scanf "%d\n%s" @@ fun n s ->
  let dp = Array.make_matrix (n + 1) (n + 1) 0 in
  for i = 0 to n - 1 do
    for j = 0 to n - 1 do
      if s.[i] = s.[j] && dp.(i).(j) < j - i then
        dp.(i + 1).(j + 1) <- 1 + dp.(i).(j)
    done
  done;
  Printf.printf "%d\n" @@
  Array.fold_left (Array.fold_left max) min_int dp


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

using namespace std;

int a,b;
string s, t, u;

int main () {
	cin >> s >> t >> a >> b >> u;
	if(u == s) {
		cout << a - 1 << " " << b;
	}
	else {
		cout << a << " " << b - 1;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 3005
using namespace std;
const int mo=1e9+7;
int n,m,len,a[N],l[N],r[N],L[N],R[N],f[N],g[N],C[N][N],vis[N],ans;
int main()
{
	int i,j,k;
	scanf("%d %d\n",&n,&m);
	for(i=1;i<=n;i++)
		a[i]=a[i-1]+getchar()-'0';
	for(i=0;i<=n;i++){
		C[i][0]=C[i][i]=1;
		for(j=1;j<i;j++)
			C[i][j]=(C[i-1][j-1]+C[i-1][j])%mo;
	  }
	f[0]=1;
	for(i=1;i<=m;i++)
		scanf("%d %d",&L[i],&R[i]);
	for(i=1;i<=m;i++)
		for(j=1;j<=m;j++)
			if(L[i]>=L[j]&&R[i]<=R[j]){
				if(L[i]!=L[j]||R[i]!=R[j]) vis[i]=1;
				else vis[i]=(j<i);
				break;
			  }
	for(i=1;i<=m;i++)
		if(!vis[i])
			++len,l[len]=L[i],r[len]=R[i];
	l[0]=1,m=len;
	for(i=0;i<m;i++){
		for(j=0;j<=n;j++) g[j]=f[j],f[j]=0;
		for(j=0;j<=r[i]-l[i]+1;j++)
			if(r[i]<l[i+1])
				f[a[r[i+1]]-a[l[i+1]-1]]=(f[a[r[i+1]]-a[l[i+1]-1]]+1LL*g[j]*C[r[i]-l[i]+1][j])%mo;
			else{
				for(k=max(j-r[i]+l[i+1]-1,0);k<=j&&k<=l[i+1]-l[i];k++)
					f[j+a[r[i+1]]-a[r[i]]-k]=(f[j+a[r[i+1]]-a[r[i]]-k]+1LL*g[j]*C[l[i+1]-l[i]][k])%mo;
			  }
	  }
	for(i=0;i<=r[m]-l[m]+1;i++)
		ans=(ans+1LL*f[i]*C[r[m]-l[m]+1][i])%mo;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 34304
n,m,x=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(n)]

ans = float('inf')
def dfs(step, m_list, cost):
    global ans
    if all(elem>=x for elem in m_list):
        ans = min(cost, ans)
    elif step != n:
        dfs(step+1, m_list, cost)
        m_list = [x+y for x, y in zip(m_list, a[step][1:])]
        cost += a[step][0]
        dfs(step+1, m_list, cost)

dfs(0, [0]*m, 0)
print(-1 if ans==float('inf') else ans)


Measured memory_bytes: 9204
#include <stdio.h>

int main() {
    int a, b, c;

    scanf("%d%d%d", &a, &b, &c);
    if (a*c <= b) {printf("%d", c);}
    else if (a > b) {printf("0");}
    else {printf("%d", b/a);}

    return 0;
}

Measured memory_bytes: 128
S = input()
ans = "Yes"
for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == "L":
            ans = "No"
            break
        else:
            continue
    else:
        if S[i] == "R":
            ans = "No"
            break
        else:
            continue
print(ans)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

const int mod = 1e9 + 7;

int main() {
  int n; cin >> n;
  vector<pair<int, int>> a;
  pair<int, int> p;
  rep(i, n) {
    int t; cin >> t;
    p.first = t;
    p.second = 0;
    a.push_back(p);
  }
  rep(i, n) {
    int t; cin >> t;
    p.first = t;
    p.second = 1;
    a.push_back(p);
  }

  sort(all(a));

  LL ans = 1;
  stack<int> x, y;
  rep(i, 2 * n) {
    if (a[i].second == 0) {
      if (y.empty()) {
        x.push(a[i].first);
      } else {
        ans *= y.size();
        ans %= mod;
        y.pop();
      }
    } else {
      if (x.empty()) {
        y.push(a[i].first);
      } else {
        ans *= x.size();
        ans %= mod;
        x.pop();
      }
    }
  }

  cout << ans << endl;
}


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

int main() {
    string S = "aeiou"s;
    char c;
    cin >> c;
    for ( size_t i = 0; i < S.size(); ++i ) {
        if ( S.at( i ) == c ) {
            cout << "vowel"s;
            return 0;
        }
    }
    cout << "consonant"s;
}

Measured memory_bytes: 256
package main 

import "fmt"

func main () {
	var x int
	var ans int
	fmt.Scan(&x)

	if x <= 599 {
		ans = 8
	}else if x <= 799 {
		ans = 7
	}else if x <= 999 {
		ans = 6
	}else if x <= 1199 {
		ans = 5
	}else if x <= 1399 {
		ans = 4
	}else if x <= 1599 {
		ans = 3
	}else if x <= 1799 {
		ans = 2
	}else{
		ans = 1
	}

	fmt.Println(ans)
}

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

namespace ProblemB
{
    class Program
    {
        static void Main(string[] args)
        {
            var NK = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var ps = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
            ps.Sort();
            var res = ps.GetRange(0, NK[1]).Sum();
            Console.WriteLine(res);

        }
    }
}


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

using namespace std;

#define sz(v)           ((int)((v).size()))
#define clr(v, d)       memset(v, d, sizeof(v))
#define rep(i, v)       for(int i=0; i<sz(v); ++i)
#define lp(i, n)        for(int i=0; i<(int)(n); ++i)
#define lpi(i, j, n)    for(int i=(j); i<(int)(n); ++i)
#define lpd(i, j, n)    for(int i=(j); i>=(int)(n); --i)
#define INF             1000000000

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

void init(){
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

const int N = 2e3+5;

int main()
{
	init();
	double a, b, x;
	cin >> a >> b >> x;
	if(x/a <= b*a/2)
		cout << setprecision(20) << 180 * (atan(b / (2*x / (a*b))) / M_PI);
	else
		cout << setprecision(20) << 180 * (atan((2 * (a*b - (x/a)) /  a) / a) / M_PI);
	return 0;
}



Measured memory_bytes: 256
a,b = map(int,input().split())

ma = 20000

for i in range(1, ma):
	p1 = i * 0.08
	p2 = i * 0.1
	if a <= p1 < a+1 and b <= p2 < b+1:
		print(i)
		exit()
print('-1')

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

#define ll long long int
#define hell 998244353
#define vi vector <ll>
#define pb push_back
#define pii pair<ll,ll>
#define vii vector <pii>
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define sep(i,a,b)  for(ll i=a-1;i>=b;i--)
#define inf (ll)(1e16)

using namespace std;

void solve()
{
    ll n;
    cin>>n;
    map < vector <ll> , ll> mp;
    rep(i,1,n+1)
    {
        string s;
        cin>>s;
        vi freq(26,0);
        rep(j,0,10)
            freq[s[j]-'a']++;
        mp[freq]++;
    }
    ll ans=0;
    for(auto ch:mp)
    {
        ans+=(ch.second*(ch.second-1))/2;
    }
    cout<<ans;

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
    //cin>>t;
    while(t--)
        solve();
    return 0;
}


Measured memory_bytes: 29952
from sys import stdin
n = int(stdin.readline())
M = [None]
M += [list(map(int, stdin.readline().split()[2:])) for i in range(n)]
sndf = [None]
sndf += [[False, i] for i in range(1, n + 1)]
tt = 0
def dfs(u):
    global tt
    sndf[u][0] = True
    tt += 1
    sndf[u].append(tt)
    for v in M[u]:
        if not sndf[v][0]:
            dfs(v)
    tt += 1
    sndf[u].append(tt)
for i in range(1, n + 1):
    if not sndf[i][0]:
        dfs(i)
    print(*sndf[i][1:])

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

int main()
{
	int i, n;
	char S[51][51];
	scanf("%d", &n);
	for (i = 1; i <= n; i++) scanf("%s", S[i]);
	
	int j, min[26], count[26] = {};
	for (j = 0; j < 26; j++) min[j] = 100;
	for (i = 1; i <= n; i++) {
		for (j = 0; j < 26; j++) count[j] = 0;
		for (j = 0; S[i][j] != 0; j++) count[S[i][j] - 'a']++;
		for (j = 0; j < 26; j++) if (count[j] < min[j]) min[j] = count[j];
	}
	
	for (j = 0; j < 26; j++) {
		for (i = 0; i < min[j]; i++) printf("%c", 'a' + j);
	}
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= 9; i++)
    {
        for (int j = 1; j <= 9; j++)
        {
            if (i * j == n)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 888
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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

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

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  ll n,m; cin >> n >> m; vector<bool> iscame(n+1,false);
  vector<vector<ll>> connect(n+1); ll cnt = 1;
  vl roomnum(n+1); 

  rep(i,m){
    ll a,b; cin >> a >> b;
    connect[a].push_back(b); connect[b].push_back(a);
  }
  
  queue<ll> q; q.push(1);
  
  while(cnt <= n){
    ll x = q.front();
    q.pop();
    
    for(ll room : connect[x]){
      if(!iscame[room]){
        cnt++;
        iscame[room] = true;
        roomnum[room] = x;
        q.push(room);
      }
    }
    
  }
  
  cout << "Yes" << endl;
  
  for(ll i=2; i <= n; i++){
    cout << roomnum[i] << endl;
  }
  
}

Measured memory_bytes: 16200
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  string S,T;
  cin>>S>>T;
  ll ans=10000;
  for(ll i=0;i<S.size()-T.size()+1;i++) {
    ll count=0;
    for(ll j=0;j<T.size();j++) {
if(S[i+j]!=T[j]) {
  count++;
}
    }
    ans=min(ans,count);
  }
  
  
  cout<<ans<<endl;
}


  

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int n;
	cin>>n;
	string s,t;
	cin>>s>>t;
	rep(i,s.size()){
		bool h=true;
		rep(j,n-i)if(t[j]!=s[i+j])h=false;
		if(h){
			cout<<n+i<<endl;
			return 0;
		}
	}
	cout<<2*n<<endl;
}









Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int x;
        int i = 0;
        while ((x = scanner.nextInt()) != 0) {
            System.out.println("Case "+(++i)+": "+x);
        }
    }
}


Measured memory_bytes: 41520
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

enum {
    LEFT, RIGHT
};

bool isOK(ll left_sq, ll right_sq) {
    if (left_sq == -1 || right_sq == -1) {
        return true;
    }

    ll l = (left_sq % 3 + 2) % 3;
    ll r = (right_sq % 3 + 2) % 3;
    return l <= r;
}

int main() {
    string s;
    while (cin >> s) {
        if (s == "#") {
            break;
        }

        ll ans = INT_MAX;

        for (ll turn : {LEFT, RIGHT}) {
            ll left_sq = -1, right_sq = -1;
            ll tmp = 0;

            for (char c : s) {
                int sq = c - '0';

                if (turn == RIGHT) {
                    if (isOK(left_sq, sq)) {
                        right_sq = sq;
                        turn = LEFT;
                    } else {
                        tmp++;
                        left_sq = sq;
                        turn = RIGHT;
                    }
                } else {
                    if (isOK(sq, right_sq)) {
                        left_sq = sq;
                        turn = RIGHT;
                    } else {
                        tmp++;
                        right_sq = sq;
                        turn = LEFT;
                    }

                }
            }

            ans = min(ans, tmp);
        }

        cout << ans << endl;
    }
}


Measured memory_bytes: 3232
n = int(input())
xs = list(map(int, input().split()))

# print(n, x)

ans = 1000000000000
i = 0
while i < 100:
  sum = 0
  for x in xs:
    sum += (x - i)**2
  if sum < ans:
    ans = sum
  i += 1

print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N,M; cin>>N>>M;
    vector<string> a(N),b(M);
    REP(i,N) cin>>a[i];
    REP(i,M) cin>>b[i];

    REP(i,N-M+1) REP(j,N-M+1){
        bool ok=true;
        REP(y,M) REP(x,M){
            if(b[y][x]!=a[i+y][j+x]) ok=false;
        }
        if(ok){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iomanip>

using namespace std;
struct color
{
    int x,y,no;
}s[100000];
int n,k,ans,sum;
int v[2000];
int main()
{
    char ch;
    scanf("%d%d",&n,&k);
    for(int i = 0;i < n;i ++)
    {
        scanf("%d %d %c",&s[i].x,&s[i].y,&ch);
        s[i].x %= k * 2;///通过移位（移动2k）都可以在这个2k*2k的图里进行操作 不改变原来的意义
        s[i].y %= k * 2;
        s[i].no = (ch == 'W' ? 1 : 0);///颜色转数字
    }
    for(int i = 0;i < k;i ++)///x坐标衡量
    {
        sum = 0;
        memset(v,0,sizeof(v));///初始化
        for(int j = 0;j < n;j ++)
        {
            int p = s[j].x >= i && s[j].x < i + k;///x坐标在i 到 i + k为一个区域
            int q = s[j].y >= 0 && s[j].y < k;///y坐标先不做限制 起点可以是0 ~ k - 1
            if(p ^ q ^ s[j].no)sum ++,v[s[j].y] ++;///先选定一种情况 满足的话 sum ++
            else v[s[j].y] --;///不满足的话
        }
        //ans = max(ans,max(sum,n - sum));
        for(int j = 0;j < k;j ++)
        {
            sum -= v[j] + v[j + k];
            ans = max(ans,max(sum,n - sum));///更新最大值，sum 和 n - sum 是黑白互换的不同结果（原来黑色的地方可以变白色，那么白色的变黑色）
        }
    }
    printf("%d",ans);
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int P[20];
int main(void){
    int N;
    cin >> N;
    for (int i = 0; i < N; i++)
        cin >> P[i];
    
    int ans = 0;
    for (int i = 1; i < N-1; i++)
        if ((P[i-1] > P[i] || P[i+1] > P[i]) && ((P[i-1] < P[i] || P[i+1] < P[i])))
            ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int A, B, C, K, count=0;
  cin >> A >> B >> C >> K;
  while(B<=A)
  {
    B *= 2;
    count++;
  }
  while(C<=B)
  {
    C *= 2;
    count++;
  }
  if(count <= K)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


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

using namespace std;

const long long int MOD = 1000000007;


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

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

	vector<string>ans;
	cin >> N;
	while (N) {
		map <vector<pair<int, int>>, int> m;
		for (int i = 0; i <= N; i++) {
			if (!i) {
				cin >> K;
				vector<pair<int, int>>vv(K);
				for (int j = 0; j < K; j++) {
					cin >> vv[j].first >> vv[j].second;
				}
				vector<pair<int, int>>v;
				for (int j = 0; j < K; j++) {
					v.push_back({ vv[j].first - vv[0].first,vv[j].second - vv[0].second });
				}
				m[v]++;
				vector<pair<int, int>>w(K);
				for (int j = 0; j < K; j++) {
					w[j].first = -v[j].first;
					w[j].second = -v[j].second;
				}
				m[w]++;
				for (int j = 0; j < K; j++) {
					w[j].first = v[j].second;
					w[j].second = -v[j].first;
				}
				m[w]++;
				for (int j = 0; j < K; j++) {
					w[j].first = -v[j].second;
					w[j].second = v[j].first;
				}
				m[w]++;
				for (int j = 0; j < K; j++) {
					v[j] = { vv[K - 1 - j].first - vv[K - 1].first ,vv[K - 1 - j].second - vv[K - 1].second };
				}
				m[v]++;
				for (int j = 0; j < K; j++) {
					w[j].first = -v[j].first;
					w[j].second = -v[j].second;
				}
				m[w]++;
				for (int j = 0; j < K; j++) {
					w[j].first = v[j].second;
					w[j].second = -v[j].first;
				}
				m[w]++;
				for (int j = 0; j < K; j++) {
					w[j].first = -v[j].second;
					w[j].second = v[j].first;
				}
				m[w]++;
			}
			else {
				cin >> K;
				vector<pair<int, int>>w(K);
				for (int j = 0; j < K; j++) {
					cin >> w[j].first >> w[j].second;
				}
				for (int j = K - 1; j >= 0; j--) {
					w[j].first -= w[0].first;
					w[j].second -= w[0].second;
				}
				if (m[w]) {
					ans.push_back(to_string(i));
				}
			}
		}
		ans.push_back("+++++");
		cin >> N;
	}
	for (auto i : ans)cout << i << endl;
	return 0;
}


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

public class Main {

    public static void main(String[] args) throws Exception {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        String s = reader.readLine();
        Integer a = Integer.valueOf(s);
        
        System.out.println((int)Math.pow(a,3));
    }

}


Measured memory_bytes: 23124
import java.util.*;

public class Main {
    static int MOD = 1000000007;
    
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        
        // ans: 要素が全て1以上k以下の長さnの数列の、gcdの総和
        long ans = 0;
        
        // 全数列のgcdを実際に計算するのは間に合わない
        // -> gcd=x(1<=x<=k)になる数列のパターン数を数える。
        
        // f(x) = gcd=xになる数列のパターン数
        // -> ans = 1*f(1) + 2*f(2) + ... + k*f(k)
        long[] f = new long[k+1];
        
        // f(x)を降順に数え上げる。
        // ex. k=12
        // f(12) <- [12,12,...,12]
        // ...
        // f(7) <- [7,7,...,7]
            // -> f(12～7) = 1
        // f(6) = f(6の倍数) - f(12)
        // f(2) = f(2の倍数) - f(4) - f(6) - ... - f(12)
            // -> f(x) = f(xの倍数) - f(2*x) - f(3*x) - ...
        for (int i = k; i >= 1; i--) {
            long baisuu = modpow((k / i), n);
            
            long tmp = 0;
            for (int j = 2 * i; j <= k; j += i) {
                tmp += f[j];
                tmp %= MOD;
            }
            
            f[i] = baisuu - tmp;
            if (f[i] < 0) {
                f[i] += MOD;
            }
        }
        
        for (int i = 1; i <= k; i++) {
            // System.out.println(f[i]);
            ans += f[i] * i;
            ans %= MOD;
        }
        System.out.println(ans);
    }
    
    public static long modpow(long a, long n) {
        long res = 1;
        while (n > 0) {
            long tmp = n & 1;
            if (tmp > 0) res = res * a % MOD;
            a = a * a % MOD;
            n >>= 1;
        }
        return res;
    }
}

Measured memory_bytes: 36672
#include <iostream>
#define N 50
#define F 31
using namespace std;

int main(){
  int n,f,a,flag,ans;
  bool d[N][F],c[N][F];
  while(1){
    cin>>n;
    if(!n) break;
    for(int i=0;i<N;i++)
      for(int j=0;j<F;j++) d[i][j]=c[i][j]=false;
    for(int i=0;i<n;i++){
      cin>>f;
      for(int j=0;j<f;j++) cin>>a,d[i][a]=c[i][a]=true;
    }
    ans=-1;
    for(int i=1;i<F;i++){
      flag=0;
      for(int j=0;j<n;j++){
	if(!d[j][i]) flag=1;
	if(c[j][i])
	  for(int k=i+1;k<F;k++)
	    if(c[j][k]){
	      for(int l=0;l<n;l++) d[l][k]=d[l][i]|d[l][k];
	      break;
	    }
      }
      if(!flag&&ans==-1) ans=i;
    }
    cout<<ans<<endl;
  }
  return 0;
}

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

int main() {
  int N;
  int K;
  int X;
  int Y;
  cin >> N;
  cin >> K;
  cin >> X;
  cin >> Y;
  int a;
  a = N * X;
if (N > K)
  a = a + (N - K) * (Y - X);
  cout << a << endl;
}

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

int comb[10];
int N,A,B,C;
int ans=100000;
int l[10];


void solve(){
  int a=0,b=0,c=0,count=0;
  for(int i=0;i<N;i++){
    if(comb[i]==1) a+=l[i];
    else if(comb[i]==2) b+=l[i];
    else if(comb[i]==3) c+=l[i];
    if(comb[i]!=0) count++;
  }
  if(a==0 || b==0 || c==0) return;
  int ansA,ansB,ansC;
  ansA=abs(A-a);
  ansB=abs(B-b);
  ansC=abs(C-c);
  ans=min(ans,ansA+ansB+ansC+(count-3)*10);
}


void dec(int x){
  if(x==N) {
    solve();
    return;
  }
  for(int i=0;i<=3;i++){
    comb[x]=i;
    dec(x+1);
  }
}

int  main(){
  cin>>N>>A>>B>>C;
  for(int i=0;i<N;i++){
    cin>>l[i];
  }
  dec(0);
  cout<<ans<<endl;

}


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

int main(void)
{
	int i;
	char s[19];
	scanf("%s", s);
	for (i = 0; i < 5; ++i)cout << s[i];
	cout << " ";
	for (i = 6; i < 13; ++i)cout << s[i];
	cout << " ";
	for (i = 14; i < 19; ++i)cout << s[i];
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>
using namespace std;

typedef long long ll;

#define REP(i,n,m) for(int i=n;i<m;i++)
#define rep(i,n) REP(i,0,n)

class State{
public:
  int x,y;
  int day;
  int a,b,c,d;

  State(){}
  State(int _x,int _y,int _day,int _a,int _b,int _c,int _d){
    x = _x;
    y = _y;
    day = _day;
    a = _a;
    b = _b;
    c = _c;
    d = _d;
  }
};

int n;

int dx[] = {0, 1,-1, 0};
int dy[] = {1, 0, 0,-1};

bool t[400][4][4];
bool closed[4][4][400][7][7][7][7];

bool check(State st){
  if(st.a == 7 || st.b == 7 || st.c == 7 || st.d == 7){
    return false;
  }

  for(int i=0;i<2;i++){
    for(int j=0;j<2;j++){
      if(t[st.day][st.y+i][st.x+j]){
        return false;
      }
    }
  }

  return true;
}

int solve(){
  queue<State> open;
  memset(closed,0,sizeof(closed));
  /*
  rep(i,3){
    rep(j,3){
      int a = (i == 0 && j == 0 ? 0 : 1);
      int b = (i == 0 && j == 2 ? 0 : 1);
      int c = (i == 2 && j == 0 ? 0 : 1);
      int d = (i == 2 && j == 2 ? 0 : 1);
      open.push(State(j,i,0,a,b,c,d));
    }
  }
  */
  open.push(State(1,1,0,1,1,1,1));
  while(!open.empty()){
    State st = open.front();
    open.pop();

    if(!check(st)){
      continue;
    }

    if(closed[st.y][st.x][st.day][st.a][st.b][st.c][st.d]){
      continue;
    }
    closed[st.y][st.x][st.day][st.a][st.b][st.c][st.d] = true;

    if(st.day == n){
      return 1;
    }



    rep(i,4){
      rep(j,3){
        int nx = st.x + j * dx[i];
        int ny = st.y + j * dy[i];

        if(nx < 0 || 2 < nx || ny < 0 || 2 < ny){
          continue;
        }

        int na = (nx == 0 && ny == 0 ? 0 : st.a + 1);
        int nb = (nx == 2 && ny == 0 ? 0 : st.b + 1);
        int nc = (nx == 0 && ny == 2 ? 0 : st.c + 1);
        int nd = (nx == 2 && ny == 2 ? 0 : st.d + 1);

        open.push(State(nx,ny,st.day+1,na,nb,nc,nd));
      }
    }
  }

  return 0;
}

int main(){
  while(cin>>n,n){
    rep(i,n){
      rep(j,4){
        rep(k,4){
          cin>>t[i][j][k];
        }
      }
    }

    cout<<solve()<<endl;
  }
}

Measured memory_bytes: 0
import java.util.Scanner;
  
public class Main{
    public void solve(){
        Scanner sc=new Scanner(System.in);
		int m = 0;
		int i = 1;
		int N = sc.nextInt();
		
        while(N != 0){
		for(int j=1; j<=N; j++){
			int k = sc.nextInt();
			
			if(k >= 2){
				 i ++;
			}else if(k == 1){
				 m ++;
			}
		}
			
			if(i >= 2){
				System.out.println(i+m);
			}else{
				System.out.println("NA");
			}
				
			 m = 0;
			 i = 1;
			 N = sc.nextInt();
		}
		
       }
        public static void main(String[]args){
        Main obj = new Main();
        obj.solve();
    }
}

Measured memory_bytes: 158608
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++){cin>>arr[i];}
    int sum=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            sum+=(arr[i]*arr[j]);
        }
    }
    cout<<sum;

}


Measured memory_bytes: 3592
#include <stdio.h>

int main()
{
  int a,b;
  scanf("%d%d",&a,&b);
  char s[a+b+1+1];
  scanf("%s",&s);
  int i;
  i = 0;
  while (s[i])
  {
    if (s[a] != '-')
    {
      //printf("%c\n",s[a]);
      printf("No\n");
      return (0);
    }
    if (!(s[i] >= '0' && s[i] <= '9') && i != a)
    {
      printf("No\n");
      return (0);      
    }
    i++;
  }
  printf("Yes\n");
}

Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int n = sc.nextInt();
			int l = sc.nextInt();
			if (n == 0) {
				break;
			}
			ArrayList<Ant> a = new ArrayList<Ant>();
			for(int i=0;i<n;i++) {
				a.add(new Ant(i+1, sc.next().charAt(0) == 'L' ? -1 : 1, sc.nextInt() * 2)); 
			}
			int step = 0;
			Ant last = null;
			while(!a.isEmpty()) {
				int m = a.size();
				for(Ant x: a) {
					x.pos += x.dir;
				}
				for(int i=0;i<m;i++) {
					Ant x = a.get(i);
					for(int j=i+1;j<m;j++) {
						Ant y = a.get(j);
						if (x.pos == y.pos && x.pos % 2 == 0) {
							x.dir *= -1;
							y.dir *= -1;
							break;
						}
					}
				}
				for (Iterator<Ant> it = a.iterator(); it.hasNext();) {
					Ant x = it.next();
					if (x.pos >= l * 2) {
						last = x;
						it.remove();
					}
				}
				for (Iterator<Ant> it = a.iterator(); it.hasNext();) {
					Ant x = it.next();
					if (x.pos <= 0) {
						last = x;
						it.remove();
					}
				}
				step++;
			}
			System.out.println(step/2 + " " + last.id);
		}

		
	}
	
	static class Ant {
		int id,dir,pos;
		public Ant(int id,int dir,int pos) {
			this.id = id;
			this.dir = dir;
			this.pos = pos;
		}
	}

}

Measured memory_bytes: 26056
#include <bits/stdc++.h>
#define int int64_t
#define M 1000000007
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;


int32_t main()
{
    //fastio;
    int t=1,n,i,j;
    //cin>>t;
    while (t--)
    {
        cin>>n;

        int a[n],dp[n];
        for(i=0;i<n;i++)
        {
            cin>>a[i];
        }
        dp[1]=abs(a[1]-a[0]);
        dp[2]=min(abs(a[2]-a[0]),dp[1]+abs(a[2]-a[1]));
        for(i=3;i<n;i++)
        {
        	dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));
        }
        cout<<dp[n-1]<<"\n";

    }
    return 0;
}

/*
    ifstream cin("input.txt");
    ofstream cout("output.txt");

    string s;
    cin>>s;
*/

Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI0(): return map(lambda s: int(s) - 1, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
def LMI0(): return list(map(lambda s: int(s) - 1, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


L, R, d = MI()
ans = 0
for i in range(L, R + 1):
    if i % d == 0:
        ans += 1
print(ans)

Measured memory_bytes: 61984
N = list(map(int, list(input())))
N.reverse()
N=N+[0]
cnt = 0
for i in range(len(N)):
  n=N[i]
  if n<5:
    cnt+=n
  elif n==5:
    cnt+=n
    if N[i+1]>=5:
      N[i+1]+=1
  else:
    cnt+=10-n
    N[i+1]+=1
print(cnt)

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

int main() {
    int a, b, k;
    cin >> a >> b >> k;
    vector<int>x;
    for(int i=1; i<=min(a, b); i++){
        if(a%i==0 && b%i==0) x.insert(x.begin(), i);
    }
    cout << x.at(k-1) << endl;
    return 0;
}



Measured memory_bytes: 256
import sys
m=166666;s=[1]*m;t=[1]*m
for i in range(m):
 for j in range(2):
  if (s[i],t[i])[j]:
   k=6*i+[5,7][j];n=[i+k,k-i-2]
   s[n[j]::k]=[0]*len(s[n[j]::k])
   t[n[1-j]::k]=[0]*len(t[n[1-j]::k])
for e in map(int,sys.stdin):
 print([e-1,sum(s[:(e+1)//6])+sum(t[:(e-1)//6])+2][e>3])


Measured memory_bytes: 9876
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cout << #x << ": " << x << endl
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

int gcd(int a, int b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int a, b;
	cin >> a >> b;
	if(b % a == 0) cout << a + b << endl;
	else cout << b - a << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
typedef pair<int,int> P;
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define rep(i, n) for (lint i = 0; i < (n); i++)
#define INF LLONG_MAX
#define all(x) (x).begin(),(x).end()
#define pb push_back
int main(){
    string str;
    cin>>str;
    bool flag=true;
    for(char ch ='a';ch<='z';ch++){
        for(int i=0;i<str.size();i++){
            if(str[i]==ch){ 
                flag=false;
            }
        }
        if(flag){
            cout<<ch<<endl;
            return 0;
        }
        flag=true;
    }
    cout<<"None"<<endl;
    return 0;
}


Measured memory_bytes: 512
def g;gets.split.map &:to_i;end
def f m,l
#p [m,l]
#puts m.map{|i|i*" "}
#puts 
d=0
(n,v=l[0];v)?(1..v).flat_map{|i|
  v%i==0&&(
    j=v/i
    y,x=$o[n]
    (y-i+1..y).flat_map{|t|
      t>=0&&m[t+i-1]&&(x-j+1..x).flat_map{|u|
        u>=0&&m[t][u+j-1]&&
        m[t,i].all?{|k|
          k[u,j].all?{|z|z==0||z==n}
        }&&(
          d=m.map{|k|k.dup}
          d[t,i]=d[t,i].map{|k|k[u,j]=[n]*j;k}
          f d,l[1..-1]
        )
      }
    }
  )
}.select{|i|i}:!m.flatten.index(0)&&[m]
end
while(x,y,n=g;x>0)
l=(1..n).map{g}
$o=[]
m=(1..y).map{|i|j=0;g.each{|c|c>0&&$o[c]=[i-1,j];j+=1}}
a=f m,l
#p a.size
#p a
puts a.size==1?a[0].map{|i|i*" "}:"NA"
end

Measured memory_bytes: 6224
#include<bits/stdc++.h>
#define ll long long
#define loop(a,b) for(ll i=a;i<b;i++)
#define iloop(a,b) for(int i=a;i<b;i++)
#define it(c) for(auto it=c.begin();it!=c.end();it++)
#define MOD 1000000007

using namespace std;

void Thai_Jase() {
    int n,x,t,temp,p;
    cin>>n>>x>>t;
    temp=x;
    p=t;
    if(x==1) {
        cout << n*t;
        return;
    }
    if(x<n) {
    while(x<n) {
        x+=temp;
        t+=p;
    }
    cout << t;
    return;
    }
    else {
        cout << t;
        return;
    }
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int ts=1;
    while(ts--) {
      Thai_Jase();
    }
    return 0;
}

Measured memory_bytes: 3584
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>
using namespace std;

int main() {
    int X, A;
    scanf("%d %d", &X, &A);
    if(X < A){
        printf("0\n");
    }else{
        printf("10\n");
    }
}

Measured memory_bytes: 128
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


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


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


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


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    A, B = map(int, input().split())
    print(A * B)


def main():
    solve()


if __name__ == '__main__':
    main()


Measured memory_bytes: 9852
#pragma comment(linker, "/STACK:102400000,102400000")
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define Key_Value ch[ch[root][1]][0]
#define DBN1(a)           cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)         cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)       cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)     cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e)   cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN6(a,b,c,d,e,f) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<", "<<#f<<"="<<(f)<<"\n"
#define clr(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define mp make_pair
#define ALL(x) x.begin(),x.end()
#define F first
#define S second
using namespace std;
typedef long long ll;
const int maxn=500000+5;
const int INF=0x3f3f3f3f;
const int P=1000000007;
const double PI=acos(-1.0);
template<typename T>
inline T read(T&x){
    x=0;int _f=0;char ch=getchar();
    while(ch<'0'||ch>'9')_f|=(ch=='-'),ch=getchar();
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x=_f?-x:x;
}
template <class T1, class T2>inline void gmax(T1 &a,T2 b){if (b>a) a=b;}
template <class T1, class T2>inline void gmin(T1 &a,T2 b){if (b<a) a=b;}
void up(int&x,int y){x+=y;if(x>=P)x-=P;}
int n,a;
int main(){
    read(n),read(a);
    if (a>=n) puts("Yes");
    else{
        for (int i=0;i<=a;i++){
            if ((n-i)%500==0) return puts("Yes"),0;
        }
        puts("No");
    }
    return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
matrix =[[0 for i in range(m+1)] for j in range(n+1)]

for i in range(n):
    a = list(map(int,input().split()))
    for j in range(m):
        matrix[i][j] = a[j]
        matrix[i][m] += a[j]
        matrix[n][j] += a[j]
        matrix[n][m] += a[j]

for i in range(0,n+1):
    print(' '.join(str(x) for x in matrix[i]))



Measured memory_bytes: 5696
import java.util.Scanner

import scala.collection.mutable.ArrayBuffer


object Main {

  class UnionFind(n: Int) {
    private val parents: ArrayBuffer[Int] = new ArrayBuffer[Int]
    private val counts: ArrayBuffer[Int] = new ArrayBuffer[Int] // rootに対しては正しい結果を保持している
    for (i <- 0 until n) {
      parents.append(i)
      counts.append(1)
    }

    def root(x: Int): Int = {
      if (parents(x) == x) x
      else {
        parents(x) = root(parents(x))
        parents(x)
      }
    }

    def sameCount(x: Int): Int = counts(root(x))

    def same(x: Int, y: Int): Boolean = root(x) == root(y)


    def unite(x: Int, y: Int): Unit = {
      if (!same(x, y)) {
        val rx = root(x)
        val ry = root(y)
        counts(ry) = counts(rx) + counts(ry)
        parents(rx) = ry
      }
    }

  }

  // A番目の島とB番目の島をつないだ橋
  case class Bridge(a: Int, b: Int)

  def read() = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    val m = sc.nextInt()
    val bridges = for (i <- 0 until m) yield {
      // 0-originにする
      val a = sc.nextInt() - 1
      val b = sc.nextInt() - 1
      Bridge(a, b)
    }
    (n, m, bridges)
  }

  def solve(n: Int, m: Int, bridges: IndexedSeq[Bridge]): IndexedSeq[Long] = {
    val reverseBridges = bridges.reverse
    val uf = new UnionFind(n)
    val numConnectedPairsDiff = for (bridge <- reverseBridges) yield {
      val diff =
        if (uf.same(bridge.a, bridge.b)) 0.toLong
        else uf.sameCount(bridge.a).toLong * uf.sameCount(bridge.b).toLong
      uf.unite(bridge.a, bridge.b)
      diff
    }
    val numConnectedPairs = numConnectedPairsDiff.scanLeft(0.toLong)(_ + _)
    numConnectedPairs.reverse.tail.map(x => n.toLong * (n.toLong - 1) / 2 - x)
  }

  def output(result: IndexedSeq[Long]) = {
    for (elem <- result) {
      println(elem)
    }

  }

  def main(args: Array[String]): Unit = {
    val (n, m, bridges) = read()
    val result = solve(n, m, bridges)
    output(result)
  }
}


Measured memory_bytes: 104860
N = int(input())
src = list(map(int,input().split()))
asc = None
ans=1
for i in range(N-1):
    #隣接項間の差
    d = src[i+1]-src[i]
        #隣接項が等しいとき
    if d==0:
        continue
    #最初または区切った直後のとき
    if asc==None:
        asc = d > 0
        continue
    #隣接項が等しくないとき:
        #ascと隣接項間の差が一致していなければ区切る
    if (asc and d<0) or (not asc and d>0):
        asc = None
        ans+=1
print(ans)

Measured memory_bytes: 14252