akhauriyash/Code-Regression huggingface dataset:
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    n,m = i_map()
    t = 1900*m +100*(n-m)
    p = 2**m
    print(t*p)



if __name__=="__main__":
    main()


Measured memory_bytes: 9476
S = input()
N = len(S)
c = 0
for i in range(N-1):
  tmp = S[:i+1]
  if len(tmp) % 2 == 1:
    continue
  n = len(tmp) // 2
  if tmp[:n] == tmp[n:] and n > c:
    c = n
print(c*2)


Measured memory_bytes: 2940
package main

import (
	"fmt"
)

func main() {
	var a, b int

	fmt.Scanf("%d %d", &a, &b)

	result, err := logic(a, b)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(result)
}

func logic(a, b int) (int, error) {
	if a%2 != b%2 {
		return 0, fmt.Errorf("IMPOSSIBLE")
	}

	return (a + b) / 2, nil
}


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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

ll dp[105][105][305];

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

void Main()
{
    arrayFill(dp, 0);

    ll n = in(), w = in();
    vint vw(n), vv(n);

    rep(i, n) cin >> vw[i] >> vv[i];

    rep(i, n) rep(j, 102) rep(k, 302)
    {
        chmax(dp[i + 1][j][k], dp[i][j][k]);
        chmax(dp[i + 1][j + 1][k + (vw[i] - vw[0])], dp[i][j][k] + vv[i]);
    }

    ll ans = 0;
    rep(j, 102) rep(k, 302)
    {
        if (j * vw[0] + k <= w)
        {
            ans = max(ans, dp[n][j][k]);
        }
    }
    cout << ans << endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

int main() {
    int H, W;
    cin >> H >> W;
    int K = 605;
    vector<string> grid(H);
    for (int i = 0; i < H; i++) cin >> grid[i];
    vector<vector<bool>> exist(K, vector<bool>(K, 0));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (grid[i][j] == '#') exist[i+j+1][i-j+300] = true;
        }
    }
    
    vector<vector<int>> xsum(K, vector<int>(K, 0)), ysum = xsum;
    for (int i = 0; i < K; i++) {
        if (exist[i][0]) xsum[i][0] = 1;
        for (int j = 1; j < K; j++) {
            xsum[i][j] = xsum[i][j-1];
            if (exist[i][j]) xsum[i][j]++;
        }
    }
    
    for (int j = 0; j < K; j++) {
        if (exist[0][j]) ysum[0][j] = 1;
        for (int i = 1; i < K; i++) {
            ysum[i][j] = ysum[i-1][j];
            if (exist[i][j]) ysum[i][j]++;
        }
    }
    ll ans = 0;
    for (int i = 0; i < K; i++) {
        for (int j = 0; j < K; j++) {
            for (int k = j+1; k < K; k++) {
                if (exist[i][j] && exist[i][k]) {
                    int dist = k-j;
                    if (i+dist < K) ans += xsum[i+dist][k] - xsum[i+dist][j-1];
                    if (i-dist >= 0) ans += xsum[i-dist][k] - xsum[i-dist][j-1];
                }
            }
        }
    }
    
    for (int i = 0; i < K; i++) {
        for (int j = i+1; j < K; j++) {
            for (int k = 0; k < K; k++) {
                if (exist[i][k] && exist[j][k]) {
                    int dist = j-i;
                    if (k+dist < K) ans += ysum[j-1][k+dist] - ysum[i][k+dist];
                    if (k-dist >= 0) ans += ysum[j-1][k-dist] - ysum[i][k-dist];
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6744
#include<algorithm>
#include<stdio.h>
using namespace std;

long long int a[100005];

int main() {
	long long int n,i,k;
	scanf("%lld%lld",&n,&k);
	for(i=0; i<n; i++) {
		long long int x,y;
		scanf("%lld%lld",&x,&y);
		a[x]+=y;
	}
	for(i=1; i<=100004; i++){
		k-=a[i];
		if(k<=0){
			printf("%lld\n",i);
			return 0;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long int
#define pb push_back
#define mk make_pair
int main(){
   int n;
   cin>>n;
   vector<ll> arr(n);
   for(int i=0;i<n;i++)
    cin>>arr[i];
  int ans=0;
  for(int i=0;i<n-2;i++){
      for(int j=i+1;j<n-1;j++){
          if(arr[j]==arr[i])
           continue;
          for(int k=j+1;k<n;k++){
             if(arr[k]==arr[i] || arr[k]==arr[j])
              continue;
             if((arr[i]+arr[j]>arr[k]) && (arr[i]+arr[k]>arr[j]) && (arr[j]+arr[k]>arr[i]))
               ans++;
          }
      }
  }
  cout<<ans<<endl;
   
}


Measured memory_bytes: 3608
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<28;
const ll INF=1ll<<50;
const double pi=acos(-1);
const double eps=1e-10;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

int n;
vi a;

int main(){
	cin>>n;
	a=vi(n);
	for(int i=0;i<n;i++) cin>>a[i];
	vvl dp(n-1,vl(21,0));
	dp[0][a[0]]++;
	for(int i=1;i<n-1;i++) for(int j=0;j<21;j++){
		int p=j+a[i],q=j-a[i];
		if(p<21) dp[i][j]+=dp[i-1][p];
		if(q>=0) dp[i][j]+=dp[i-1][q];
	}
	cout<<dp[n-2][a[n-1]]<<endl;
}

Measured memory_bytes: 3152
#include <iostream>
using namespace std;
int main(void){
  string s;
  cin >> s;
  long long sum = 0;
  for (int i = 0 ; i < s.length() ;i++)
  sum += s[i]-48;
  if (sum % 9 == 0)
  cout <<"Yes";
  else cout << "No";
}


Measured memory_bytes: 3748
#include <iomanip>
#include <iostream>

using namespace std;

int main()
{
    double a,b,C;
    int A,B;
    cin >> a >> b;
    C=a/b;
    A=a;
    B=b;
    cout << fixed;
    cout << A/B <<" " << A%B << " " << setprecision(8)<< C << endl;
}


Measured memory_bytes: 3260
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String input = scanner.nextLine();
        int ramenPrice = 700;

        for(int i=0; i<input.length(); i++) {
            if(input.charAt(i) == 'o') {
                ramenPrice += 100;
            }
        }
        System.out.println(ramenPrice);
    }
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    string sa, sb;
    int a, b;
    cin>>a>>b;
    int i;
    FOR0(i, a) sb += to_string(b);
    FOR0(i, b) sa += to_string(a);
    if(sa < sb) cout<<sa<<endl;
    else cout<<sb<<endl;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

Measured memory_bytes: 256
//37
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  int N;
  cin>>N;
  for(int i=0;i<N;i++){
    int l[3];
    cin>>l[0]>>l[1]>>l[2];
    sort(l,l+3);
    cout<<((l[0]*l[0]+l[1]*l[1]==l[2]*l[2])?"YES":"NO")<<endl;
  }
  return 0;
}

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

int main() {
  int d, t, s;
  cin >> d >> t >> s;
  if ((1.0 * d) / s <= 1.0 * t) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  getchar();
}

Measured memory_bytes: 3632
#include <cstdio>
#include <map>

using namespace std;

int main()
{
	map<int, int> customers;
	int cid;
	char cdata[1024];

	while (fgets(cdata, sizeof(cdata), stdin), *cdata != '\n'){
		sscanf(cdata, "%d,%*d", &cid);
		if (customers.count(cid)) customers[cid] += 2;
		else customers.insert(make_pair(cid, 2));
	}
	while (~scanf(" %d,%*d", &cid)){
		if (customers.count(cid)){
			if (customers[cid] % 2 == 0) customers[cid]++;
			customers[cid] += 2;
		}
	}
	for (map<int, int>::iterator it = customers.begin(); it != customers.end(); it++){
		if (it->second % 2 != 0){
			printf("%d %d\n", it->first, it->second / 2);
		}
	}

	return (0);
}

Measured memory_bytes: 1048
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
    long n,x;
    cin >> n >> x;
    long l[n];
    rep(i,n){
        cin >> l[i];
    }
    int cnt = 0;
    long now = 0;
    if(0<=x) cnt++;
    rep(i,n){
        now+=l[i];
        if(now<=x) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	int a,kin,wari;
	public void solve(){
		Scanner sc=new Scanner(System.in);
		
		int n=sc.nextInt();
		
		for(int i=0;i<n;i++){
			int x=sc.nextInt();
			int y=sc.nextInt();
			int b=sc.nextInt();
			int p=sc.nextInt();
			
			kin=x*b+y*p;
			
			if(b>=5 && p>=2){
				wari=kin*4/5;
			}else{
				if(b<5){
					b=5;
					}if(p<2){
						p=2;
					}
					wari=(x*b+y*p)*4/5;
					}if(kin>wari){
						kin=wari;
					}
					System.out.println(kin);
					}
	}
					public static void main(String[] args){
						Main obj = new Main();
						obj.solve();
					}
}

Measured memory_bytes: 23400
/*
Write a program which reads an integer n (n &#8804; 50) and identifies the number of combinations of a, b, c, and d (0 &#8804; a, b, c, d &#8804; 9) which meet the following equality:

        a + b + c + d = n
For example, for n = 35, we have 4 different combinations of (a, b, c, d): (8, 9, 9, 9), (9, 8, 9, 9), (9, 9, 8, 9), (9, 9, 9, 8).
 */

#include <iostream>

using namespace std;

int calc(int a, int b, int n) {
	int tmp = n-a-b;
	int count = 0;
	for (int c=0; c<10; c++) {
		for (int d=0; d<10; d++) {
			if (tmp == c+d)
				count++;
		}
	}
	return count;
}

void solve(int n) {
	int count = 0;
	for (int a=0; a<10; a++) {
		for (int b=0; b<10; b++) {
			count += calc(a,b,n);
		}
	}
	cout << count << endl;
}

int main() {
	int n;
	while (cin >> n) {
		solve(n);
	}
	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<stdlib.h>
int main(){
  int n, i, ans=10000, x=0,y=0,z=0,j;
  scanf("%d", &n);
  int w[n+1];
  for(i=1;i<=n;i++){
    scanf("%d", &w[i]);
    z+=w[i];
  }
  for(i=1;i<=n;i++){
    for(j=1;j<=i;j++){
      x+=w[j];
    }
    y=z-x;
    if(ans>abs(x-y)){
      ans=abs(x-y);
    }
    x=0;
    y=0;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), x = scanner.nextInt();
			int[] m = new int[n];
			int sum = IntStream.range(0, n).map(i -> m[i] = scanner.nextInt()).sum();
			int min = Arrays.stream(m).min().getAsInt();
			System.out.println((x - sum) / min + n);
		}
	}
}


Measured memory_bytes: 30036
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int N, A, B, C;
int l[11];
int cost[1111];

int f(int a, int b, int c, int i)
{
    if (i == N) {
        if (a == 0 || b == 0 || c == 0) {
            return INF;
        } else {
            return abs(a - A) + abs(b - B) + abs(c - C);
        }
    }

    int rtnA = f(a + l[i], b, c, i + 1) + (a == 0 ? 0 : 10);
    int rtnB = f(a, b + l[i], c, i + 1) + (b == 0 ? 0 : 10);
    int rtnC = f(a, b, c + l[i], i + 1) + (c == 0 ? 0 : 10);
    int rtn0 = f(a, b, c, i + 1);
    return min(min(min(rtnA, rtnB), rtnC), rtn0);
}

int main()
{
    cin>>N>>A>>B>>C;
    REP(i,N) {
        cin>>l[i];
    }
    REP(i,1001) {
        cost[i] = INF;
    }
    cout<<f(0,0,0,0)<<endl;

    return 0;
}


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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a == b){
    cout << c << endl;
  }else if(a == c){
    cout << b << endl;
  }else if(b == c){
    cout << a << endl;
  }
}

Measured memory_bytes: 256
# print('input >>')
N, X, Y = map(int,(input().split()))
ans = [0] * N

for i in range(1, N+1):
    for j in range(i, N+1):
        choku = j-i
        tanraku = abs(X-i) + abs(Y-j) + 1
        ans[min(choku, tanraku)] += 1

# print('-----output-----')
for ans_e in ans[1:]:
    print(ans_e)

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define p pair<string,int>
int N;
vector<p> a, b;
int main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        string S;
        int P;
        cin >> S >> P;
        a.push_back({S, -P});
        b.push_back({S, -P});
    }
    sort(a.begin(), a.end());
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            if(a[i] == b[j]) cout << j + 1 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstring>
#include<bitset>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<numeric>
#include<set>
#include<math.h>
#include<unordered_map>
using namespace std;

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

#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)

long long INF=1e9;
const int mod=10007;
#define ll long long

int main(){
    int n,ans=0;
    cin>>n;
    while(n){
        int a=n%10;
        n/=10;
        if(a==2)ans++;
    }
    cout<<ans<<endl;
    return 0;
}


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

struct UnionFind{
    int data[100001]; 
    void init(int n){memset(data,-1,sizeof(data));}
    int find(int x){return data[x]<0?x:data[x]=find(data[x]);}
    void unite(int x, int y){
        x=find(x);y=find(y);       
        if(x!=y){
            if(data[y]<data[x]) swap(x,y);
            data[x]+=data[y];data[y]=x;
        }
        return;
    } 
    bool same(int x, int y){return (find(x) == find(y));}
    int size(int x){return -data[x];}
};
int main(){
    int n,m,q;
    cin>>n>>m;
    UnionFind uf;
    uf.init(n+1);
    int s,t;
    rep(i,m){
        cin>>s>>t;
        uf.unite(s,t);
    }
    cin>>q;
    rep(i,q){
        cin>>s>>t;
        if(uf.same(s,t)) cout<<"yes"<<endl;
        else cout<<"no"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3528
D=int(input())
c=list(map(int,input().split()))
s=[]
t=[]
v=0
lastday=[0 for i in range(26)]

for i in range(D):
  tmp=list(map(int,input().split()))
  s.append(tmp)
  
for i in range(D):
  ans=1+(D-i)%26
  print(ans)

Measured memory_bytes: 9512
h, w = raw_input().split(" ")
h, w = int(h), int(w)

a = []
for i in range(h):
   a.append([int(x) for x in raw_input().split(" ")])

#print(a)
move = []

for i in range(h):
    for j in range(w-1):
        if a[i][j] & 1:
            a[i][j], a[i][j+1] = 0, a[i][j] + a[i][j+1]
            move.append((i+1,j+1,i+1,j+1+1))

e = w-1
for i in range(h-1):
    if a[i][e] & 1:
        a[i][e], a[i+1][e] = 0, a[i][e] + a[i+1][e]
        move.append((i+1,e+1,i+1+1,e+1))
#print(a)
print(len(move))
#print(move)
for step in move:
    print("{} {} {} {}".format(*step))

Measured memory_bytes: 59548
def resolve():
  S = list(input())
  T = list(input())

  min_count = len(T)
  for i in range(len(S) - len(T) + 1):
    temp_counter = 0
    for t in range(len(T)):
      if T[t] != S[i + t]:
        temp_counter += 1
    if temp_counter < min_count:
      min_count = temp_counter

  print(min_count)

if __name__ == "__main__":
  resolve()

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

int main() {
  string s, t;
  cin >> s;
  cin >> t;
  int sum = 0;
  
  for (int i=0; i<s.size(); i++) {
    if (s.at(i) != t.at(i)) {
      sum++;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3912
# -*- coding: utf-8 -*-
# dwacon6th-prelims/dwacon6th_prelims_b
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

MAX = 10**5 + 100
MOD = 10**9 + 7

fac = [1, 1] + [0] * MAX
finv = [1, 1] + [0] * MAX
inv = [1, 1] + [0] * MAX
coef = [1, 1] + [0] * MAX

for i in range(2, MAX):
    fac[i] = fac[i - 1] * i % MOD
    inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
    finv[i] = finv[i - 1] * inv[i] % MOD
    coef[i] = coef[i - 1] * i % MOD + fac[i - 1] % MOD

def main():
    N = i2n()
    n = N - 1
    x = i2nn()
    total = 0
    for i in range(1, N):
        d = x[i] - x[i - 1]
        total = (total + (coef[i] * fac[n] % MOD * finv[i] % MOD * d % MOD)) % MOD
    print(total)
    return

main()


Measured memory_bytes: 32432
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
    string S;
    cin >> S;
    if(S == "Sunny") cout << "Cloudy"<<endl;
    else if(S=="Cloudy") cout << "Rainy"<<endl;
    else if(S=="Rainy") cout << "Sunny"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
char ch[N]; int n, cnt, c[N], tmp, res = 1e9;
inline void check (int mx) {
	int mn = 0, t = 0;
	for (int i = 1; i <= n; ++i) {
		if (ch[i] == '0') ++t;
		else if (ch[i] == '1') --t;
		else (t + 1 + c[i + 1] <= mx) ? ++t : --t;
		mn = min (mn, t);
	} res = min (res, mx - mn);
} 
signed main() {
	scanf ("%s", ch + 1); n = strlen (ch + 1); 
	for (int i = n; i >= 1; --i)
		c[i] = max (0, c[i + 1] + (ch[i] == '0' ? 1 : -1));
	for (int i = 1; i <= n; ++i) {
		(ch[i] == '0') ? ++cnt : --cnt;
		tmp = max (tmp, cnt);
	} check (tmp), check (tmp + 1);
	return printf ("%d\n", res),  0;
}

Measured memory_bytes: 8744
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrep(i,a,b) for(int i=(int)(a);i>=(int)(b);--i)
#define fore(i,a) for(auto &i:a)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define isin(i,a,b) ((a) <= (i) && (i) < (b))
#define uni(a) (a).erase(unique(all(a)),(a).end())
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll  = long long;
using unit= unsigned;
using ull = unsigned long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vvi = vector<vi>;
using vp  = vector<P>;
void _main(); int main(){ cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T>void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T>void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T>void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T>void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T>bool chmax(T &a, const T &b){ if (a<b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if (b<a){ a = b; return 1; } return 0; }
template<class T>T gcd(T a, T b){ if (b==0){ return a; }else{ return gcd(b, a%b); }}
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
constexpr double eps = 1e-10;
constexpr int inf = INT_MAX / 2;
constexpr ll infl = 1LL << 60;

void _main() {
  int X, A;
  cin >> X >> A;

  int ans = (X < A) ? 0 : 10;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define REPR(i,n) for(int i=n-1; i>=(int)(0); i--)
#define FOR(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define FORR(i,a,b) for(int i=(int)(b)-1; i>=(int)(a); i--)
#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()
//**関数リスト**//
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: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
ll nod(ll F) {
	ll keta = 1;
	while (F / 10 > 0) {
		keta++;
		F /= 10;
	}
	return keta;
}
ll gcd(ll x, ll y) {
	ll r;
	if (x < y) {
		swap(x, y);
	}
	while (y > 0) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
ll isPrime(ll x) {
	ll i;
	if (x < 2) {
		return 0;
	}
	else if (x == 2) {
		return 1;
	}
	else if (x % 2 == 0) {
		return 0;
	}
	else {
		for (i = 3; i * i <= x; i += 2) {
			if (x % 1 == 0) {
				return 0;
			}
		}
		return 1;
	}
}
void eratos(vl isPrime) {
	//(注)isPrimeのサイズはN+1にする！実際にはmain内に配置して使用
	ll i, j;
	REP(i, isPrime.size()) {
		isPrime[i] = 1;
	}
	isPrime[0] = 0; isPrime[1] = 0;
	for (i = 2; i * i <= isPrime.size() - 1; i++) {
		if (isPrime[i] == 1) {
			j = i * 2;
			while (j <= isPrime.size() - 1) {
				isPrime[j] = 0;
				j = j + i;
			}
		}
	}
}
ll modinv(ll a, ll m) {
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
void bitSearch(ll n) {
	//実際にはコピーして中身を改変して使う
	ll i;
	REP(i, pow(2, n)) {
		ll p = i;
		REP(i, n) {
			cout << p % 2;
			p /= 2;
		}
		cout << endl;
	}
}

void bfs(ll now) {
	//中身は毎回書き換えて使用
	queue<ll> Q;
	Q.push(now);
	ll u;
	while (!Q.empty()) {
		u = Q.front();
		Q.pop();
		//ll v=;
		//Q.push(v);
	}
}
//**定義場所**//
ll i, j, k, l, m, n;
ll N, M, K, H, W;
ll MOD = 1000000007;
ll ans = 0;
//***********//

int main() {
	cin >> N;
	vl A(N+1);
	vl B(N+1);
	for (i = 1; i <= N; i++) {
		cin >> A[i];
		B[i] == 0;
	}
	ll M = N / 2 + 1;
	for (i = N; i >= M; i--) {
		B[i] = A[i];
		ans += B[i];
	}
	for (i = M - 1; i >= 1; i--) {
		ll sum = 0;
		ll j = i;
		ll k = j;
		while (j + k <= N) {
			j += k;
			sum += B[j];
		}
		B[i] = abs(sum%2 - A[i]);
		ans += B[i];
	}
	cout << ans << endl;
	for (i = 1; i <= N; i++){
		if (B[i] == 1) {
			cout << i << endl;
		}
	}
}

Measured memory_bytes: 3968
#include<stdio.h>
int main(){
	int a, b, c, d;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	if(a==1){
		if(b==9){
			if((c==7&&d==4)||(c==4&&d==7))
				printf("YES");
			else
				printf("NO");
		}
		else if(b==7){
			if((c==9&&d==4)||(c==4&&d==9))
				printf("YES");
			else
				printf("NO");
		}
		else if(b==4){
			if((c==7&&d==9)||(c==9&&d==7))
				printf("YES");
			else
				printf("NO");
		}
		else
			printf("NO");
	}
	else if(a==9){
		if(b==1){
			if((c==7&&d==4)||(c==4&&d==7))
				printf("YES");
			else
				printf("NO");
		}
		else if(b==7){
			if((c==1&&d==4)||(c==4&&d==1))
				printf("YES");
			else
				printf("NO");
		}
		else if(b==4){
			if((c==7&&d==1)||(c==1&&d==7))
				printf("YES");
			else
				printf("NO");
		}
		else
			printf("NO");
	}
	else if(a==7){
		if(b==9){
			if((c==1&&d==4)||(c==4&&d==1))
				printf("YES");
			else
				printf("NO");
		}
		else if(b==1){
			if((c==9&&d==4)||(c==4&&d==9))
				printf("YES");
			else
				printf("NO");
		}
		else if(b==4){
			if((c==1&&d==9)||(c==9&&d==1))
				printf("YES");
			else
				printf("NO");
		}
		else
			printf("NO");
	}
	else if(a==4){
		if(b==9){
			if((c==7&&d==1)||(c==1&&d==7))
				printf("YES");
			else
				printf("NO");
		}
		else if(b==7){
			if((c==9&&d==1)||(c==1&&d==9))
				printf("YES");
			else
				printf("NO");
		}
		else if(b==1){
			if((c==7&&d==9)||(c==9&&d==7))
				printf("YES");
			else
				printf("NO");
		}
		else
			printf("NO");
	}
	else
		printf("NO");
	return 0;
}

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

int main(){
    int N, M;
    cin >> N >> M;

    int L, R;
    int left = 1, right = N;

    for(int i = 1; i <= M; i++){
        cin >> L >> R;
        if(left < L) left = L;
        if(right > R) right = R;
    }

    cout << max(right-left+1, 0) << "\n";

    return 0;
}

Measured memory_bytes: 256
n, g = map(int, input().split())
List = [list(map(int, input().split())) for i in range(n)]

ans = []

max_score = [(i+1)*100*List[i][0]+List[i][1] for i in range(n-1, -1, -1)] #全て答えたときのスコアを算出(逆順)
score = [(i+1)*100 for i in range(n-1, -1, -1)] #各レベルの点数を算出しておく(逆順)
howmany = [List[i][0] for i in range(n-1, -1, -1)] #回数も逆順に出しておく

for i in range(2**n):
    s = 0
    m = 0
    max = 0 #残りの中で最も得点の単位が大きいもの
    for j in range(n):
        if((i >> j) & 1):
            max += 1
            s += max_score[j]
            m += howmany[j]
    if(s >= g):
        ans.append(m)
    else:
        if(max < n):
            rest = g - s
            k = -(-rest // score[max]) #最も得点の単位の高い問題を何問解くか
            if(k < howmany[max]):
                m += k
                ans.append(m)

print(min(ans))

Measured memory_bytes: 3064
N,L = map(int,input().split())
count = L
taste = []
for i in range(N):
    taste.append(count)
    count += 1
if 0 in taste:
    taste.remove(0)
elif  N + L <= 0:
    taste.pop(-1)
else:
    taste.pop(0)
print(sum(taste))

Measured memory_bytes: 9180
import java.util.Scanner;


// 152_b
public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] p = new int[n];

        for (int i = 0; i < n; i++) {
            p[i] = sc.nextInt();
        }

        int count = 0;
        int min = Integer.MAX_VALUE;

        for (int i = 0; i < n; i++) {
            if (p[i] < min) {
                count++;
                min = p[i];
            }
        }

        out(count);

    }

    /*
     * 以下メソッド集
     */

    static long gcd(long a, long b) {

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

    static int gcd(int a, int b) {

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

    static void out(String info) {

        System.out.println(info);
    }

    static void out(int info) {

        System.out.println(info);
    }

    static void out(double info) {

        System.out.println(info);
    }

    static void out(long info) {

        System.out.println(info);
    }

}


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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

template<typename T>
ll sz(vector<T> vec){ return (ll)vec.size(); }
ll sz(string s){ return (ll)s.size(); }

int main(){
    ll n;
    cin >> n;
    n++;
    ll a[n] = {};
    rep(i,0,n){
        cin >> a[i];
    }

    P cnt[n] = {};
    cnt[n-1] = P(a[n-1],a[n-1]);
    rep(k,1,n){
        ll i = n-k-1;
        cnt[i].fs = cnt[i+1].fs/2 + cnt[i+1].fs%2 + a[i];
        cnt[i].sc = cnt[i+1].sc + a[i];
    }
    if(cnt[0].fs > 1){
        cout << -1 << endl;
        return 0;
    }
    
    ll memo = 1,ans = 0;
    rep(i,0,n){
        memo = min(cnt[i].sc,memo);
        ans += memo;
        memo -= a[i];
        memo *= 2;
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 5924
f = {}
for x = 1, 100 do
  for y = 1, x do
    for z = 1, y do
    val = x * x + y * y + z * z + x * y + x * z + y * z
      if val <= 10000 then
        if x == y and y == z then
          f[val] = (f[val] or 0) + 1
        elseif (x == y and y ~= z) or (x == z and x ~=y) or(y == z and y ~= x) then
          f[val] = (f[val] or 0) + 3
        elseif (x ~= y and x ~= z and y ~= z) then
          f[val] = (f[val] or 0) + 6
        end
      end
    end
  end
end
n = io.read("*n")
for k = 1, n do print(f[k] or 0) end


Measured memory_bytes: 2772
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値
#include <functional>//sort第三引数greater<型名>()で降順
#include <map>

using namespace std;
using ll = long long int;

int main(){
    int N;cin>>N;
    vector<int> d(N);
    map<int,int> m;
    for(int i=0;i<N;i++){
        cin >> d[i];
        m[d[i]]++;
    }
    sort(d.begin(),d.end());
    d.erase(unique(d.begin(),d.end()),d.end());
    int sum = 0;
    int p = d.size()-1;
    int ans = 0;
    for(int i=d[p];i>0&&sum<=N/2;i--){
        if(i==d[p]){
            sum += m[d[p]];
            p--;
        }
        if(sum==N/2) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6600
#include<iostream>
#include<cstdio>
#include<cstring>

using namespace std;

int D;
unsigned long long G,v[1111],w[1111],sum,cnt,minn=1000000000000ull;
bool check[1111];

int main(){
	cin>>D>>G;
	for(int i=0;i<D;++i)cin>>v[i]>>w[i];
	for(int i=0;i<1<<D;++i){
		cnt=sum=0ll;
		memset(check,false,sizeof(check));
		for(int j=0;j<D;++j)if(i&(1<<j))sum+=v[j]*(j+1ull)*100ull+w[j],cnt+=v[j],check[j]=true;
		if(sum>=G)goto endd;
		for(int j=D-1;~j;--j){
			if(check[j])continue;
			for(int k=1;k<=v[j];++k){
				sum+=(j+1ull)*100ull;
				++cnt;
				if(sum>=G)goto endd;
			}
		}
		endd:
		minn=min(minn,cnt);
	}
	cout<<minn;
}

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

const int max_N = 5e5 + 21;

#define ls(x) ((x)<<1)
#define rs(x) (ls(x)|1)
#define mid ((l+r)>>1)
#define lch ls(x),l,mid
#define rch rs(x),mid+1,r

int n,K,p[max_N],q[max_N],seg[max_N<<2],pos[max_N],ans[max_N];

bool vis[max_N];

std::priority_queue<int>pq;

inline void update(int x){
	seg[x]=std::max(seg[ls(x)],seg[rs(x)]);
}

void build(int x,int l,int r){
	if(l==r){seg[x]=p[l],pos[l]=x; return;}
	build(lch),build(rch),update(x);
}

void modify(int x,int v){
	x=pos[x],seg[x]=v;
	for(x>>=1;x;x>>=1)update(x);
}

int ql,qr,qa;

void query(int x,int l,int r){
	if(ql<=l&&r<=qr){qa=std::max(qa,seg[x]); return;}
	if(ql<=mid)query(lch); if(qr>mid)query(rch);
}

void check(int id){
	if(id<0||id>(n-1)/K)return;
	ql=id*K+1,qr=ql+K-1,qa=0,query(1,1,n);
	if(!qa||vis[qa])return;
	int tmp=qa;
	ql=q[qa]-K+1,qr=q[qa]+K-1,qa=0,query(1,1,n);
	if(tmp!=qa)return;
	vis[qa]=1,pq.push(q[qa]);
}

int main(){
	scanf("%d%d",&n,&K);
	for(int i=1;i<=n;++i){
		scanf("%d",p+i);
		q[p[i]]=i;
	}
	build(1,1,n);
	for(int i=0;i<=(n-1)/K;++i)check(i);
	for(int i=n;i;--i){
		int x=pq.top();
		pq.pop(),ans[x]=i,modify(x,0);
		int id=(x-1)/K;
		check(id-1),check(id),check(id+1);
	}
	for(int i=1;i<=n;++i)
		printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 21744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;

bool cmp(string a,string b){
	if(a.size()==b.size()) return a>=b;
	else return a.size()>b.size();
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;cin >> n >> m;
	vector<bool> a(10);
	vector<int> b={0,2,5,5,4,5,6,3,7,6};
	rep(i,m){
		int x;cin >> x;
		a.at(x)=true;
	}
	vector<string> dp(10100);
	rep(i,n){
		if(i!=0 && dp[i]=="") continue;
		rep(j,10){
			if(a.at(j)){
				char c='0'+j;
				if(cmp(c+dp[i],dp[i+b.at(j)])) dp[i+b.at(j)]=c+dp[i];
			}
		}
	}
	cout << dp[n] << endl;
}


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

int main() {
  int a;
  int b;
  cin >> a >> b;
  int c;
  c=(a*b)%2;
  if(c==0){
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" <<endl;
  }
}


Measured memory_bytes: 256
import java.util.*;
 
class Main{
	public static void main(String args[]) {
		Scanner sc=new Scanner(System.in);
 
		String s =sc.next();
		char c[]=s.toCharArray();
		int count=0;
		int max=0;
		
		for( int i=0;i<s.length();++i) {
			if (c[i]=='A' ||c[i]=='C' ||c[i]=='G' ||c[i]=='T') {
				++count;
				max=Math.max(count, max);
			}
			else count=0;
		}
		
		System.out.println(max);

	}
	
}

Measured memory_bytes: 21716
import math

n,k=map(int,input().split())
A=list(map(int,input().split()))

#lk=str(int(math.log2(k)+1))
lk=str(41)

B=[]
for i in range(n):
    B.append(format(A[i],str(lk.zfill(2))+"b"))

#print(B)

P=[]
ss=1
for i in range(41-1,-1,-1):
    po0=0
    po1=0
    for j in range(n):
        
        if B[j][i]=="1" :
            po0+=ss
        else :
            po1+=ss
    P.append([po0,po1])
    ss*=2

#print(P)

pmax=[]
for i in range(len(P)):
    pmax.append(max(P[i]))

k2=str(format(k,"b"))
k22=str(format(k,"041b"))
#print(k22)

le=1
ri=1
ma=0
for i in range(1,len(k22)+1):
    ma+=P[i-1][int(k22[-i])]
ma1=ma


#print(str(ma)+" "+str(k2))
    
while ri<=len(k2) :
    if k2[-ri]=="0" :
        ri+=1
    else :
        ma2=ma1
        for i in range(le,ri):
            ma2-=P[i-1][0]
            ma2+=pmax[i-1]
        ma2-=P[ri-1][1]
        ma2+=P[ri-1][0]
        #print(str(ma2)+" "+str(ma)+" "+str(le)+" "+str(ri))
        #print(ma)
        ma=max(ma,ma2)
        ma1=ma2
        le=ri
        ri+=1

print(ma)


Measured memory_bytes: 17892
from collections import defaultdict

S = input()
T = input()

S_dict, T_dict = defaultdict(list), defaultdict(list)
for i, s in enumerate(S):
    S_dict[s].append(i)
for i, t in enumerate(T):
    T_dict[t].append(i)

S_set, T_set = set(), set()
for s in S_dict.values():
    S_set.add(tuple(s))
for t in T_dict.values():
    T_set.add(tuple(t))

print('Yes' if S_set == T_set else 'No')


Measured memory_bytes: 23856
#include <bits/stdc++.h>  
 
using namespace std;
 
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)
#define MOD 1e9 + 7
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

int main() {
	int N;
	scanf("%d", &N);
	rep(i, N) {
		string a, b;
		string ans;
		cin >> a >> b;
		int a_tmp, b_tmp;
		int k = (a.size() > b.size()) ? a.size() : b.size();
		int tmp = max(a.size(), b.size()) - min(a.size(), b.size());
		rep(j, tmp) (a.size() > b.size()) ? b.insert(0, "0") : a.insert(0, "0");
		int keta = 0;
		repr(j, k - 1) {
			a_tmp = a[j] - 48; b_tmp = b[j] - 48;
			int sum = a_tmp + b_tmp + keta;
			if(sum < 10) {
				keta = 0;
				stringstream ss;
				ss << sum;
				ans.insert(0, ss.str());
			}
			else {
				keta = 1;
				sum = sum - 10;
				stringstream ss;
				ss << sum;
				ans.insert(0, ss.str());
			}
		}
		if(keta == 1) ans.insert(0, "1");
		if(ans.size() > 80) printf("overflow\n");
		else cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;
vector<int> E[2020];
set<int> S[2020];

int D[2020][2020];
bitset<2020> B[2020],C[2020];
ll ret;

void dfs(int cur,int pre,int id,int d) {
	D[id][cur]=d;
	FORR(e,E[cur]) if(e!=pre) dfs(e,cur,id,d+1);
}

void add(int a,int b) {
	if(a==b || S[a].count(b)) return;
	
	int i;
	FOR(i,2) {
		FORR(e,S[a]) {
			if(D[a][e]+D[e][b]==D[a][b]) {
				add(e,b);
				return;
			}
			if(D[a][b]+D[b][e]==D[a][e]) {
				vector<pair<int,int>> V;
				vector<int> W;
				V.push_back({a,b});
				V.push_back({b,e});
				
				int te=e;
				S[a].erase(te);
				S[te].erase(a);
				FORR(e,S[a]) if(D[a][b]+D[b][e]==D[a][e]) W.push_back(e);
				FORR(w,W) S[a].erase(w),S[w].erase(a),V.push_back({b,w});
				FORR(v,V) add(v.first,v.second);
				return;
			}
		}
		swap(a,b);
	}
	S[a].insert(b);
	S[b].insert(a);
}

void dfs2(int cur,int pre,int root) {
	FORR(e,S[cur]) if(D[root][e]+D[e][cur]==D[root][cur]) B[cur] |= B[e];
	FORR(e,E[cur]) if(e!=pre) dfs2(e,cur,root);
	
}


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(i,N-1) {
		cin>>x>>y;
		E[x-1].push_back(y-1);
		E[y-1].push_back(x-1);
	}
	FOR(i,N) dfs(i,i,i,0);
	
	FOR(i,M) {
		cin>>x>>y;
		add(x-1,y-1);
	}
	
	FOR(i,N) {
		FOR(x,N) {
			B[x]=B[2000];
			B[x][x]=1;
		}
		dfs2(i,i,i);
		FOR(x,N) C[x]|=B[x];
	}
	FOR(i,N) ret+=C[i].count()-1;
	
	cout<<ret/2<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 17920
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        String[] c = new String[h];
        for (int i = 0; i < c.length; i++) {
            c[i] = sc.next();
        }
        for (int i = 0; i < c.length; i++) {
            for (int j = 0; j < 2; j++) {
                System.out.println(c[i]);
            }
        }
    }
}

Measured memory_bytes: 38040
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int a, b, c; cin >> a>>b>>c;
	if (a == b + c || b == a + c || c == a + b)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline
    k,a,b = map(int, input().split())
    if a+2>=b:
        print(int(k+1))
        exit()
    print(((k-a+1)//2)*(b-a)+(k-a+1)%2+a)


Measured memory_bytes: 2940
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

ll nCm(ll n, ll m){
    if(m == 0 || m == n){
        return 1;
    } else if(m == 1){
        return n;
    }
    return (nCm(n - 1, m) + nCm(n - 1, m - 1));
}

//-----------------------ここから-----------

int main(void){
    int n, a;
    cin >> n >> a;
    cout << n * n - a << endl;
}

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

int main()
{
    int m1, m2, d1, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if (m2 == m1 + 1) cout << 1;
    else cout << 0;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll seg[800005];

ll query(ll ql,ll qr, ll l, ll r, ll ind){
	if(ql<=l && qr>=r){
		return seg[ind];
	}
	if(l>qr || ql>r){
		return 0;
	}
	ll m=(l+r)/2;
	return max(query(ql,qr,l,m,2*ind+1),query(ql,qr,m+1,r,2*ind+2));
}

void update(ll ind, ll val, ll l, ll r, ll ti){
	if(ind<l || ind>r){
		return;
	}
	if(l==r){
		seg[ti]=val;
		return;
	}
	ll m=(l+r)/2;
	update(ind,val,l,m,2*ti+1),update(ind,val,m+1,r,2*ti+2);
	seg[ti]=max(seg[2*ti+1],seg[2*ti+2]);
	return;
}

int main(){
	ll i,n,h[200005],c[200005],sum;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>h[i];
	}
	for(i=0;i<n;i++){
		cin>>c[i];
	}
	for(i=0;i<n;i++){
		sum=query(0,h[i],0,n,0);
		update(h[i],sum+c[i],0,n,0);
		// cout<<sum+c[i]<<" ";
	}
	cout<<seg[0]<<endl;
}

Measured memory_bytes: 9472
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

const M: usize = 1_000_000_007;

fn main() {
    input! {
        n: usize, k: usize,
        a: [usize; n],
    }
    let mut dp = vec![vec![0; k + 1]; n + 1];
    dp[0][k] = 1;

    for i in 1..n + 1 {
        let mut sum = vec![0; k + 1];
        for j in 0..k + 1 {
            if j > 0 {
                sum[j] += sum[j - 1];
            }
            sum[j] += dp[i - 1][j];
            sum[j] %= M;
        }
        for j in 0..k + 1 {
            dp[i][j] += if j + a[i - 1] > k {
                sum[k]
            } else {
                sum[j + a[i - 1]]
            };
            dp[i][j] %= M;
            dp[i][j] += M;
            dp[i][j] -= if j > 0 { sum[j - 1] } else { 0 };
            dp[i][j] %= M;
        }
    }
    println!("{}", dp[n][0]);
}


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

int main(){
    long long N, K;
    cin >> N >> K;
    long long d, A;
    long long i;
    long long j;
    bool A_have[N+1];
    for(i=1; i<=N; i++){
        A_have[i] = 0;
    }
    for(i=1; i<=K; i++){
        cin >> d;
        for(j=1; j<=d; j++){
            cin >> A;
            A_have[A]=1;
        }
    }
    long long counta=0;
    for(i=1; i<=N; i++){
        if(A_have[i]==0){
            counta++;
        }
    }
    cout << counta << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 3700