akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;

	public static void Main(string[] args)
	{
		var n = Console.ReadLine().ToInt();
		var s = Console.ReadLine();
		var p = Console.ReadLine().ToInt();
		for(int i = 0; i < n; i++)
		{
			if(s[i] != s[p-1])
			{
				Console.Write("*");
			}
			else
			{
				Console.Write(s[i]);
			}
		}
		Console.WriteLine();
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

Measured memory_bytes: 13140
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1

""" Input
N = int(input())
N, A, B = map(int, input().split())
A = list(map(int, input().split()))
A = np.array(input().split(), dtype=np.float64)
D = [int(input()) for _ in range(N)]
AB = [[int(x) for x in input().split()] for _ in range(N)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
"""


S = input().rstrip()
ans = 0

for s in S:
    if s == '+':
        ans += 1
    else:
        ans -= 1

print(ans)

# def main():

# if __name__ == '__main__':
#     main()


Measured memory_bytes: 3568
#include <stdio.h>
#include <math.h>

int main() {
    int n, ans = 10000000;
    int sum;
    int x[100] = {};
    scanf("%d", &n);
    for (int i = 0; i < n; i++){
        scanf("%d ", &x[i]);
    }
    for (int i = 0; i < 101; i++) {
        sum = 0;
        for (int j = 0; j < n; j++) {
            sum += pow(x[j] - i, 2);
        }
        if (ans > sum)
            ans = sum;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>  
using namespace std;  
//????\???????????????????????§????????????????ITC-LMS??????????????§???????????????????????????IMAC??????????????????????????¨????´???´???????????¨???????????????
//			?§?????????????C++?????????????????§????????????????????\???????\???????????????£??¨??°????????¨????????£????????????????????????????????????????????????????????????????°???????????????°???????????????????°??????????????????????
  
const int MAX_NUM = 10000;
const int MAX_LENGTH = 1000000;
   
long value[MAX_NUM];
long sum,min_num,max_num;  

int main()  
{    
	int n;  
	cin >> n;        
	for( int i=0; i<=n-1; i++ )  
	{  
		cin >> value[i];  
	}  

	min_num = value[0];
	max_num = value[0];
	for( int i=0; i<=n-1; i++ )  
	{  
		if ( value[i] < min_num )
		{
			min_num = value[i];
		}
		if ( value[i] > max_num )
		{
			max_num = value[i];
		}
		sum += value[i];
	}  
	cout << min_num << ' ' << max_num << ' ' << sum << endl;    
 
	return 0;  
}  

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

namespace abc152_d
{
  class Program
  {
    static void Main(string[] args)
    {
      var N = CIn.ReadInt();

      var a = new int[10, 10];

      for (int i = 1; i <= N; i++)
      {
        var t = i.ToString()[0] - '0';
        var b = i % 10;
        a[t, b]++;
      }

      var ans = 0;

      for (int i = 0; i <= N; i++)
      {
        if (i % 10 != 0)
        {
          var t = i.ToString()[0] - '0';
          var b = i % 10;

          ans += a[b, t];
        }
      }

      Console.WriteLine(ans);
    }
  }

  static class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(long n)
    {
      var array = new string[n];
      for (var i = 0L; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(long n)
    {
      var array = new int[n];
      for (var i = 0L; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(long n)
    {
      var array = new long[n];
      for (var i = 0L; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(long n)
    {
      var array = new double[n];
      for (var i = 0L; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }

    public static char[,] ReadCharMatrix(long h, long w)
    {
      var array = new char[h, w];
      for (var i = 0L; i < h; i++)
      {
        var l = Console.ReadLine().ToCharArray();
        for (var j = 0L; j < w; j++)
        {
          array[i, j] = l[j];
        }
      }
      return array;
    }
  }
}


Measured memory_bytes: 15432
#include <iostream>
#include <vector>
#include <cstdio>
using namespace std;

int N, M, Q; 
vector<vector<int>> sum;

int buildSumTable(vector<int> L, vector<int> R){
    sum = vector<vector<int>>(N + 1, vector<int>(N + 1, 0));
    for(int i=0; i<M; i++) sum[L[i]][R[i]]++;

    for(int i=1; i<=N; i++){
        for(int j=1; j<=N; j++){
            sum[i][j] += sum[i-1][j];
            sum[i][j] += sum[i][j-1];
            sum[i][j] -= sum[i-1][j-1];
        }
    }
}

int getSumRange(int L, int R){
    int ans = sum[R][R] - sum[R][L-1] - sum[L-1][R] + sum[L-1][L-1];
    return ans;
}

int main() {
    scanf("%d %d %d", &N, &M, &Q); //cin >> N >> M >> Q;
    vector<int> L(M), R(M);
    for(int i=0; i<M; i++) scanf("%d %d", &L[i], &R[i]); //cin >> L[i] >> R[i];
    vector<int> p(Q), q(Q);
    for(int i=0; i<Q; i++) scanf("%d %d", &p[i], &q[i]); //cin >> p[i] >> q[i];

    buildSumTable(L, R);

    for(int i=0; i<Q; i++){
        int ans = getSumRange(p[i], q[i]);
        printf("%d\n", ans); //cout << ans << endl;
    }
}


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

using namespace std; 

#define pb push_back
#define fi first
#define se second
#define all(vec) vec.begin(),vec.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define fr(i,a,b) for(int i=a;i>=b;i--)
#define fp(i,a,b,p) for(int i=a;i<b;i+=p)
#define SZ(x) (int)x.size()

typedef  vector<string> vs;
typedef  vector<int> vi;
typedef  vector<long long> vl;	





int main(){

	vi v;
	f(i,1,201){
		if(i%2==0) continue;
		int cnt=0;
		fr(j,i,1){
			if(i%j==0)cnt++;
		}
		
		if(cnt==8) v.pb(i);
	}
	
	int n;
	
	cin >> n; 
	
	int ans = 0;
	f(i,0,SZ(v)){
		if(v[i]<=n) ans++;
	}
	cout << ans << endl;
	
    return 0;
}


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

#define INF_P 1100000000
#define INF_M -1100000000
#define MAX(a,b) a<b?b:a
#define MIN(a,b) a>b?b:a

struct item{
    int weight;
    int value;
};

int n, w;
int dp[10001];
struct item goods[100];

int main(void) 
{
    int i, j, ans = -1;
    scanf("%d %d",&n, &w);

    for (i = 0; i < n; i++) {
        scanf("%d %d",&goods[i].value, &goods[i].weight);
    }

    for (i = 0; i < n; i++) {
        for (j = w-1; j > 0; j--) {
            if (dp[j] && j + goods[i].weight <= w) {
                dp[j+goods[i].weight] = 
                    MAX(dp[j+goods[i].weight],dp[j]+goods[i].value);
            }
        }
        dp[goods[i].weight] = 
                    MAX(dp[goods[i].weight],goods[i].value);
    }
    
    for (i = 0; i <= w; i++) {
        if (ans < dp[i]) {
            ans = dp[i];
        }
    }

    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define int         long long   
#define double      long double
#define endl        "\n"
#define pb          push_back
#define PI          3.1415926535897932384626433832795l
#define F           first
#define S           second
#define mp          make_pair
#define f(i,n)      for(int i=0;i<n;i++)
#define fastio      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)      (v).begin(),(v).end()
#define sort(v)     sort((v).begin(),(v).end())
#define rall(v)     (v).rbegin(),(v).rend()
#define rsort(v)     sort((v).rbegin(),(v).rend())
#define gcd(a,b)    __gcd((a),(b))
#define minn(v)     *min_element(v.begin(), v.end());
#define maxx(v)     *max_element(v.begin(), v.end());
#define print(x)    cout<<(x)<<endl;
typedef pair<int,int> pii;  
typedef vector<int> vi;
//x.substr(start, length);
/*
// Create a vector containing n 
//vectors of size m.  
    vector<vector<int> > vec( n , vector<int> (m, 0));  
*/
struct type{
    int k, i, j;
};
//to check if a no is prime or not?
bool isPrime(int n) 
{ 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
}

// minimum subaaray sum of size k-sliding window approach
int findSubarray(int arr[], int n, int k)
{
	int window_sum = 0;
	int min_window = INT_MAX;
	int last = 0;
	for (int i = 0; i < n; i++)
	{
		window_sum += arr[i];
		if (i + 1 >= k)
		{
			if (min_window > window_sum)
			{
				min_window = window_sum;
				last = i;
			}
			window_sum -= arr[i + 1 - k];
		}
	}
	int sum=0;
	for(int i=last-k+1;i<=last;i++)
	{
	    sum+=arr[i];
	}
	return sum;
}
signed main() 
{
    fastio;
    //cout << fixed << setprecision(0);
    int x,y;
    cin>>x>>y;
    bool flag=true;
    for(int i=0;i<=x;i++)
    {
        if((i*2+4*(x-i))==y)
        {
            cout<<"Yes"<<endl;
            flag=false;
            break;
        }
    }
    if(flag)cout<<"No"<<endl;
}


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

int main()
{
  int n,k,tx[100001],dis,ans=1000000000;
  cin >> n >> k >> tx[0];
  for(int i=1;i<k-1;i++)
  {
    cin >> tx[i];
  }
  for(int i=k-1;i<n;i++)
  {
    cin >> tx[i];
    dis = tx[i]-tx[i-k+1];
    if(tx[i]<=0 && tx[i-k+1]<=0)dis-=tx[i];
    else if(tx[i]>=0 && tx[i-k+1]>=0)dis+=tx[i-k+1];
    else dis+=min(-tx[i-k+1],tx[i]);
    if(dis<ans)ans=dis;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
import std.stdio;

void main() {
    int n, d, x;
    readf("%d\n", &n);
    readf("%d %d\n", &d, &x);
    long result = x;
    foreach (i; 0 .. n) {
        int a;
        readf("%d\n", &a);
        for (int day = 1; day <= d; day += a) {
            ++result;
        }
    }
    writeln(result);
}


Measured memory_bytes: 256
import collections
N=int(input())
SS=[]
answer=0
for _ in range(N):
    s=input()
    s=sorted(s)
    S=''
    for a in s:
        S+=a
    SS.append(S)
a=collections.Counter(SS)
for n in a.values():
   answer+=(n-1)*n/2
print(int(answer))


Measured memory_bytes: 69848
#include<iostream>
#include<string>

using namespace std;

int main()
{string S,T;
 cin >> S >> T;
 string begin(26,-1);
 string end(26,-1);
 
 bool flag = true; 
 
 for(int i = 0; i < S.size(); i++){
   int a = S[i] - 'a';
   int b = T[i] - 'a';
   
   if(begin[a] != -1 || end[b] != -1){
     if(begin[a] != b || end[b] != a){
       flag = false;
       break;}}
     
   begin[a] = b;
   end[b] = a;}

 if(flag){cout << "Yes" << endl;}
 else{cout << "No"<<endl;}
 return 0;}


Measured memory_bytes: 776
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
  int n, m, c; cin >> n >> m >> c;
  vector<int> b(20);
  vector<vector<int>> a(20, vector<int>(20));

  REP(i, m) cin >> b[i];
  REP(i, n) { 
    REP(k, m) cin >> a[i][k];
  }

  int ans = 0;
  REP(i, n) {
    int sum = 0;
    REP(k, m) {
      sum += a[i][k] * b[k];
    }
    if (sum + c > 0) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int MAX(int a,int b){return a<b?b:a;}
//int P[1010],L[1010],R[1010],H[1010],C=1;
int P[3][1010],H[1010],C=1;
//int hyouka(int i,int x){return N[i]<=x?N[i]<x?-1:0:1;}
char N[1010][110];
int hyouka(int i,char *s){return strcmp(s,N[i]);}
int h(int a){return H[P[2][a]]-H[P[1][a]];}
void rot(int a,int t){//L==1,R==2
  int b=P[3-t][a],r=P[0][a];
  P[1][r]==a?(P[1][r]=b):(P[2][r]=b);
  if(P[2][b])P[0][P[2][b]]=a;
  P[3-t][a]=P[t][b];
  P[t][b]=P[0][b];
  P[0][b]=P[0][a];
  P[0][a]=b;
  H[a]=MAX(H[P[1][a]],H[P[2][a]])+1;
  H[b]=MAX(H[P[1][b]],H[P[1][b]])+1;
}
void rotr(int a){//printf("r %d\n",a);
  int b=P[1][a],r=P[0][a];
  P[1][r]==a?(P[1][r]=b):(P[2][r]=b);
  if(P[2][b])P[0][P[2][b]]=a;
  P[1][a]=P[2][b];
  P[2][b]=P[0][b];
  P[0][b]=P[0][a];
  P[0][a]=b;
  H[a]=MAX(H[P[1][a]],H[P[2][a]])+1;
  H[b]=MAX(H[P[1][b]],H[P[1][b]])+1;
}
void rotl(int a){//printf("l %d\n",a);
  int b=P[2][a],r=P[0][a];
  P[1][r]==a?(P[1][r]=b):(P[2][r]=b);
  if(P[1][b])P[0][P[1][b]]=a;
  P[2][a]=P[1][b];
  P[1][b]=P[0][b];
  P[0][b]=P[0][a];
  P[0][a]=b;
  H[a]=MAX(H[P[1][a]],H[P[2][a]])+1;
  H[b]=MAX(H[P[1][b]],H[P[2][b]])+1;
}
int mfind(char *x){
  int i,j,r,n;
  if(C==1){
    P[1][0]=C;
    //N[C]=x;
    strcpy(N[C],x);
    H[C]=1;
    P[0][C++]=0;
    return 1;
  }
  for(i=P[1][0];r=hyouka(i,x);i=n){//printf("%d %s\n",r,x);
    if(r<0){
      if(P[1][i]==0){
	P[1][i]=C;
	P[0][C]=i;
	H[i]=MAX(2,H[i]);
	//N[C]=x;
	strcpy(N[C],x);
	H[C]=1;
	C++;
      }
      n=P[1][i];
    }
    else{
      if(P[2][i]==0){
	P[2][i]=C;
	P[0][C]=i;
	H[i]=MAX(2,H[i]);
	strcpy(N[C],x);
	//N[C]=x;
	H[C]=1;
	C++;
      }
      n=P[2][i];
    }
  }//printf("%d\n",i);
  //for(j=0;j<C;j++){
  // printf(":%d %d %d %d %s\n",P[0][j],P[1][j],P[2][j],H[j],N[j]);
  //}
  j=P[0][i];
  while(1){
    H[j]=MAX(H[P[1][j]],H[P[2][j]])+1;
    if(h(j)<-1){
      if(h(P[1][j])>0)rot(P[1][j],1);
      rot(j,2);
      break;
    }
    if(h(j)>1){
      if(h(P[2][j])<0)rot(P[2][j],2);
      rot(j,1);
      break;
    }
    if(h(j)==0)break;
    j=P[0][j];
    if(j==0)break;
  }//printf("%d\n",i);
  return i;
}      
void prim(int n){
  int i;
  if(P[1][n])prim(P[1][n]);
  for(i=0;i<H[n];i++)printf("  ");
  printf("%s\n",N[n]);
  if(P[2][n])prim(P[2][n]);
}
/*int main(){
  int n,i;
  //for(i=0;i<100;i++)H[i]=-1;
  char s[10];
  while(~scanf("%s",s)){
    printf("%d\n",mfind(s));
    for(i=0;i<C;i++){
      printf("%d %d %d %d %s\n",P[0][i],P[1][i],P[2][i],H[i],N[i]);
    }
    prim(P[1][0]);printf("end\n");
  }
  return 0;
}/*/
int main(){
  int i,l,max=0,mj=1,r,a[1010]={};
  char *c,*mi,s[1020];
  fgets(s,1010,stdin);
  mi=strtok(s," \n");
  a[mj=mfind(mi)]++;
  max=strlen(mi);
  // printf("%s\n",mi);
  while(c=strtok(NULL," \n")){
    //printf("%s\n",c);
    a[r=mfind(c)]++;
    //printf("%d\n",r);
    l=strlen(c);//printf("%s %d\n",mi,l);
    if(max<l){
      max=l;
      strcpy(mi,c);
    }//printf("a\n");
    if(a[r]>a[mj])mj=r;//printf("a\n");
  }
  //printf("%s %d\n",mi,mj);
  printf("%s %s\n",N[mj],mi);
  return 0;
  }//*/

Measured memory_bytes: 564
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7
#main code here!
    s=SI()
    count=0
    for i in range(4):
        if s[i]=="2":
            count+=1
    print(count)
        
        
        
        
    
if __name__=="__main__":
    main()



Measured memory_bytes: 67480
import math

def isprime(x):
    if x == 2: return True
    if x % 2 == 0: return False
    for i in range(3, math.ceil(math.sqrt(x)) + 1, 2):
        if x % i == 0: return False
    return True

n = int(input())
count = 0
for i in range(n):
    x = int(input())
    if isprime(x): count += 1
print(count)

Measured memory_bytes: 6816
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j, z, key;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ){
    scanf("%d", &A[i]);
  }
  
  /* trace(A, n);*/
  
  for ( i = 1; i <= n; i++ ){
    key = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > key){
      A[j+1] = A[j];
      j = j - 1;
      A[j+1] = key;
    }
    for(z=1;z<n;z++){
      printf("%d ",A[z]);
    }
    printf("%d\n",A[z]);
  }
    
  return 0;
}

Measured memory_bytes: 600
class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0]*(n+1)
 
    def to_sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= (i & -i)
        return s
 
    def add(self, i, x):
        while i <= self.n:
            self.data[i] += x
            i += (i & -i)
 
    def get(self, i, j):
        return self.to_sum(j)-self.to_sum(i-1)

import sys
input = sys.stdin.readline
N,Q = map(int,input().split())
C = list(map(int,input().split()))
#print(C)
LR = []
ans = [0 for _ in range(Q)]
for i in range(Q):
  temp= list(map(int,input().split()))
  LR.append((temp,i)) #クエリとID
LR.sort(key=lambda x : x[0][1]) #右端で昇順にソート
#print(LR)
CMAX = max(C)
Tree = BIT(N)
last = [-1 for _ in range(CMAX)] #色を0index
left,right = LR[0][0]
for j in range(right):
  mae = last[C[j]-1]
  last[C[j]-1] = j
  if mae !=-1:
    Tree.add(mae+1,-1) #BITは1から
  Tree.add(last[C[j]-1]+1,1) #BITは1から
  #print(Tree.get(left,right))
#print(last)
D = []
#for i in range(1,N+1):
#  detemp = Tree.get(i,i)
#  D.append(detemp)
#print(D)

temp = Tree.get(left,right)
ID = LR[0][1]
ans[ID] = temp
lastright = right  
#print(Tree.get(left,right))
for i in range(1,Q):
  left,right = LR[i][0]
  #print(right,lastright)
  if lastright < right:
    for j in range(lastright,right):
      mae = last[C[j]-1]
      last[C[j]-1] = j
      #print(C[j],mae,j,last[C[j]-1] )
      if mae !=-1:
        #rint(C[j],"A")
        Tree.add(mae+1,-1) #BITは1index
      Tree.add(j+1,1) #BITは1index
  temp = Tree.get(left,right)
  ID = LR[i][1]
  ans[ID] = temp
  lastright = right
  #print(last)


print(*ans,sep="\n")



Measured memory_bytes: 227736
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#define debug(x) cout << #x " => " << (x) << endl
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int n;
  cin >> n;
  vector<string> s(n);
  vector<int> t(n);
  rep (i, n) cin >> s[i] >> t[i];
  string x;
  cin >> x;
  lint sum = 0;
  bool ok  = true;
  rep (i, n) {
    if (!ok) sum += t[i];
    if (s[i] == x) ok = false;
  }
  cout << sum << endl;
  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++)
int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}
vector<int> input(int n) {
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<int> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    return;
}
vector<vector<int>> input(int n, int m) {
    vector<vector<int>> table(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table. at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n,r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
    }
    return fact;
}
int gcd(int a, int b)
{
    if (a % b == 0)
    {
        return(b);
    }
    else
    {
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int main() {
  string s;
  cin >> s;
  int x=s.size();
  cout << s[0] << x-2 << s[x-1] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define DUMP(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<": "<<(x)<<" (L"<<__LINE__<<")"<<endl
using namespace std;
using vint = vector<int>;
using vdouble = vector<double>;
using vstring = vector<string>;
using ll = long long;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

using P = pair<int, int>;

constexpr int manhattanDist(P student, P point) {
    return abs(student.first - point.first) + abs(student.second - point.second);
}

int main() {
    int n, m; cin >> n >> m;
    vector<P> student(n), point(m);
    rep(i, n) {
        int a, b; cin >> a >> b;
        student[i] = P(a, b);
    }
    rep(i, m) {
        int c, d; cin >> c >> d;
        point[i] = P(c, d);
    }
    rep(i, n) {
        int mnd = 1e9, mxj = 0;
        rep(j, m) {
            int d = manhattanDist(student[i], point[j]);
            if(d < mnd) {
                mnd = d;
                mxj = j;
            }
        }
        cout << (mxj + 1) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
        String line  = sc.nextLine();
        
        for(int i = 0; i < line.length(); i++){
            if(Character.isLowerCase(line.charAt(i))){
                System.out.print(Character.toUpperCase(line.charAt(i)));
            }
            
            else if(Character.isUpperCase(line.charAt(i))){
                System.out.print(Character.toLowerCase(line.charAt(i)));
            }
            
            else {
                System.out.print(line.charAt(i));
            }
        }
        
        System.out.println();
    }
}


Measured memory_bytes: 26888
#include <iostream>

using namespace std;

int main(){
    long long n, a, b;
    cin >> n >> a >> b;
    long long temp = n / (a + b);
    temp = temp * a;
    long long temp2 = n % (a + b);
    if(temp2 > a) cout << temp + a;
    else cout << temp + temp2;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
  int n, tmp;
  int i;
  long long ans = 0, abc, absum = 0;
  vector <long> ab;
  cin >> n;
  vector<int> a, b, c;

  for(i = 0; i < n; i++){
    cin >> tmp;
    a.push_back(tmp);
  }
  for(i = 0; i < n; i++){
    cin >> tmp;
    b.push_back(tmp);
  }
  for(i = 0; i < n; i++){
    cin >> tmp;
    c.push_back(tmp);
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  sort(c.begin(),c.end());

  for(i = 0; i < n; i++){
    absum += lower_bound(a.begin(),a.end(),b[i])-a.begin();
    ab.push_back(absum);
  }
  for(i = 0; i < n; i++){
    abc = lower_bound(b.begin(),b.end(),c[i])-b.begin();
    if(abc > 0){
      ans += ab[abc-1];
    }
  }

  cout << ans << endl;

  return 0;

}


Measured memory_bytes: 2552
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n;
    cin>>n;
    vector<int> v={111,222,333,444,555,666,777,888,999};
    cout<<*lower_bound(v.begin(),v.end(),n)<<endl;
}

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

int main(){
  int h,w;
  cin >> h >> w;
  vector<string> str(h);
  for(int i=0;i<h;i++){
    cin >> str.at(i);
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(str.at(i).at(j)=='#'){
        cout << '#';
        continue;
      }
      int cnt=0;
      if(i-1>=0&&j-1>=0&&str.at(i-1).at(j-1)=='#'){cnt++;}
      if(i-1>=0&&str.at(i-1).at(j)=='#'){cnt++;}
      if(i-1>=0&&j+1<w&&str.at(i-1).at(j+1)=='#'){cnt++;}
      if(j-1>=0&&str.at(i).at(j-1)=='#'){cnt++;}
      if(j+1<w&&str.at(i).at(j+1)=='#'){cnt++;}
      if(i+1<h&&j-1>=0&&str.at(i+1).at(j-1)=='#'){cnt++;}
      if(i+1<h&&str.at(i+1).at(j)=='#'){cnt++;}
      if(i+1<h&&j+1<w&&str.at(i+1).at(j+1)=='#'){cnt++;}
	  cout << cnt;
    }
    cout << endl;
  }
}


Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl;
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0;
#define HERE cout<<"    "<<"HERE"<<en

int game[4][205];

int main(){
  int n;
  cin>>n;
  for(int i=1; i<=n; i++){
    for(int j=1; j<=3; j++){
      cin>>game[j][i];
    }
  }
  
  
  int ans[205];
  for(int i=0; i<=n; i++) ans[i]=0;
  
  for(int i=1; i<=3; i++){
    for(int j=1; j<=n; j++){
      bool there=false;
      for(int k=1; k<=n; k++){
        if(k==j) continue;
        if(game[i][j]==game[i][k]){
          there=true;
          break;
        }
      }
      if(!there) ans[j]+=game[i][j];
    }
  }
  
  for(int i=1; i<=n; i++){
    cout<<ans[i]<<en
  }
}



Measured memory_bytes: 3084
use std::io;
use std::str::FromStr;
use std::cmp;


fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn main(){
    let num:Vec<i32> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let max_num = cmp::max(num[0], num[1]);
    let min_num = cmp::max(num[0], num[1]);
    let pieces = 16 - max_num * 2;
    if max_num - min_num <= pieces / 2{
        println!("Yay!");
    }
    else{
        println!(":(");
    }
}


Measured memory_bytes: 4352
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

nn = inputs[0][0].to_s

# body
if $debugFlag
  p nn
end

tmp_min = 1000
(nn.length-2).times do |i|
  x = (nn[i..i+2].to_i - 753).abs
  tmp_min = x if x < tmp_min
end

puts tmp_min

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <math.h>
#include <stdlib.h>
using namespace std;

int main(){
  int a,b,c,d;
  cin >> a>>b>>c>>d;
  if(abs(a-c)<=d||(abs(a-b)<=d&&abs(b-c)<=d)){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios::sync_with_stdio(0); cin.tie(0);
#define endl '\n'
int main()
{
    fast;
    ll n,x; cin>>n>>x;
    ll a=n-x;
    cout<<3*(n-__gcd(n,x))<<"\n";
    return 0;
}


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

int main(){
  int N,A;
  int amari, b;
  cin >> N >> A;
  amari = N % 500;
  if ( amari <= A ) {
     cout << "Yes" << endl;
  }
  else {
     cout << "No" << endl;
  }
}


Measured memory_bytes: 256
N,M = map(int, input().split())
E = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    E[a-1].append(b-1)

from collections import deque

d = N+1
flag = False
for i in range(N):
    for v in E[i]:
        q = deque()
        q.append(v)
        used = [N+1]*N
        used[v] = 1
        while q:
            temp = q.popleft()
            if used[temp] > d:
                break
            for u in E[temp]:
                if u == i and d > used[temp]+1:
                    d = used[temp]+1
                    memo = [temp, u]
                    q = deque()
                    flag = True
                    break
                elif u == i:
                    q = deque()
                    break
                if used[u] < N+1:
                    continue
                used[u] = used[temp]+1
                q.append(u)

import heapq
if flag:
    h = []
    dist = [N+1]*N
    dist[memo[1]] = 0
    for v in E[memo[1]]:
        heapq.heappush(h, (1, v))
    while True:
        temp = heapq.heappop(h)
        if dist[temp[1]] < N+1:
            continue
        dist[temp[1]] = temp[0]
        if temp[1] == memo[0]:
            break
        for v in E[temp[1]]:
            if dist[v] < N+1:
                continue
            heapq.heappush(h, (temp[0]+1, v))
    ans = [memo[0]]
    d = dist[memo[0]]-1
    prev = memo[0]
    while d >= 0:
        for i in range(N):
            if dist[i] == d and prev in E[i]:
                prev = i
                ans.append(i)
                d -= 1
                break
    print(len(ans))
    for i in ans:
        print(i+1)
else:
    print(-1)

Measured memory_bytes: 3700
#include <stdio.h>
int main(void) {
    int i,j,n,m,p[1000],temp,sum;
    while (1) {
        scanf("%d %d",&n,&m);
        if (n==0&&m==0) break;
        sum=0;
        for (i=0; i<n; i++) scanf("%d",&p[i]);
        for (i=0; i<n; i++) {
            for (j=0; j<n-1-i; j++) {
                if (p[j]>p[j+1]) {
                    temp=p[j];
                    p[j]=p[j+1];
                    p[j+1]=temp;
                }
            }
        }
        temp=n-1;
        while ((temp+1)/m!=0) {
            for (i=0; i<m-1; i++) {
                sum+=p[temp-i];
            }
            temp-=m;
        }
        for (i=temp; i>=0; i--) {
            sum+=p[i];
        }
        printf("%d\n",sum);
    }
    return 0;
}

Measured memory_bytes: 600
def main():
  s=input()[::-1]
  l,mod=len(s),2019
  x=[0]*mod
  x[0]=1
  a,t=0,1
  for i in range(l):
    a = (a + int(s[i])*t) % 2019
    x[a]+=1
    t=(t*10)%mod
  ans=sum([i*(i-1)//2 for i in x])
  print(ans)
if __name__=='__main__':
  main()

Measured memory_bytes: 9364
#include <iostream>
#include <string>

using namespace std;


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

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

int main() {
  int AB, BC, CA;
  cin >> AB >> BC >> CA;


  if(AB > BC){
    if(AB > CA){
      cout << BC * CA / 2;
    }
    else{
      cout << AB * BC / 2;
    }
  }
  else{
    if(BC > CA){
      cout << AB * CA / 2;
    }
    else{
      cout << AB * BC / 2;
    }
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        String c = sc.next();
        if (a.substring(a.length() - 1, a.length()).equals(b.substring(0, 1)) && b.substring(b.length() - 1, b.length()).equals(c.substring(0, 1))) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }

}

Measured memory_bytes: 21844
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;


int main(void) {
	string s,t;
	cin >> s >> t;
	sort(s.begin(),s.end());
	sort(t.begin(),t.end());
	reverse(t.begin(),t.end());
	if(s<t){
		cout << "Yes" << endl;
	}else {
		cout << "No" << endl;
	}
	return 0;
}


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

#define ll long long
#define mod 1000000007
#define pll pair<long long,long long>
#define pdd pair<long double,long double>
#define vll vector<ll>
#define rep(i,j,n) for(int i=j;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define inf 1e17
priority_queue<pll,vector<pll>,greater<pll> >pq;
priority_queue<ll,vector<ll>,greater<ll> >pq1;

ll result(ll a, ll b, ll p){
    ll ans=1;
    if(b==(-1))
        b=p-2;
    while(b){
        if(b&1){
            ans=(ans*a)%p;
        }
        a=(a*a)%p;
        b>>=1;
    }
    return ans;
}

int main(){
    if(fopen("input.txt", "r"))
    freopen("input.txt", "r", stdin),
    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, a,b;
    cin >> a >> b;
    ll p=10*b;
    ll ans=-1;
    for(ll i=p;i<p+10;i++){
        if((i*8)/100==a){
            ans=i;
            break;
        }
    }
    cout<<ans;

    return 0;
        
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}
template<typename T,typename U>
ll FindErase(T &v,U tar){
  ll cnt = 0;
  for(auto it = v.begin(); it != v.end();){
    if(*it == tar){
      it = v.erase(it);
      ++cnt;
    }
    else{
      ++it;
    }
  }
  return cnt;
}

struct Edge{
  int to;
  long long cost;
};

struct NODE{
  int pos;
  long long cost;
};
bool operator < (const NODE &a,const NODE &b){
  return a.cost > b.cost;
}
vector<Edge> g[100000],rg[100000];

int N;
vector<int> memo(500,inf),tmp;
bool dfs(int p,int k){
  bool f = false;
  if(memo[p] == 0) return true;
  if(memo[p] != inf) return false;
  memo[p] = k;
  for(auto n: g[p]){
    f |= dfs(n.to,k+1);
  }
  return f;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int u,d;
  string s;
  set<int> st;
  const int X = 200;
  rep(i,n){
    cin >> u >> s >> d;
    st.insert(u);
    st.insert(d+X);
    if(s == "lock"){
      g[d+X].push_back({u,1});
    }
    else{
      g[u].push_back({d+X,1});
    }
  }
  bool ans = false;
  tmp = memo;
  for(auto n: st){
    memo = tmp;
    ans |= dfs(n,0);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 7864
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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; }

int main () {
  int n, m;
  cin >> n >> m;
  int ans = n*(n-1)/2;
  ans += m*(m-1)/2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
sn=[0]*100001
mi2=0
mi=0
for i in range(0,n):
    if sn[a[i]]==1:
        mi2=1-mi2
    else:
        sn[a[i]]=1
        mi+=1
print(mi-mi2)

Measured memory_bytes: 14396
//header{{{
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/math/common_factor_rt.hpp>
  
using namespace std;
//using namespace boost;
//using namespace multiprecision;  

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

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

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

    int a,b;
    cin >> a >> b;

    for(int i = 0; i <= 100000; ++i){
        if(int(i * 0.08) == a && int(i * 0.1) == b){
            cout << i << '\n';
            return 0;
        }
    }

    cout << "-1\n";        

    return 0;
}


Measured memory_bytes: 256
from math import sqrt, sin, cos, pi

a, b, C = map(float, input().split())

#度からラジアンへ変換する
C = (C * pi) / 180

#余弦定理を使って計算する
c = sqrt(a**2 + b**2 - 2*a*b*cos(C))
height = b * sin(C)
size = a * height * (1/2)
length = a + b + c

#出力する
print('{:.8f}'.format(size))
print('{:.8f}'.format(length))
print('{:.8f}'.format(height))


Measured memory_bytes: 5696
#include<cstdio>
#include<cmath>
using namespace std;
long long a[1000];
int main()
{
	long long k;
	int n=50;
	scanf("%lld",&k);
	if(k==0)
	{
		printf("%d\n",n);
		for(int i=1;i<=n;i++)
			printf("%d ",n-1);
		printf("\n");
		return 0;
	}
	for(int i=1;i<=n;i++)
		a[i]=(k-1)/n+n;
	int pos;
	long long b=(a[1]-(n-1))*n-k;
	long long mx;
	while(b)
	{
		mx=-1;
		for(int i=1;i<=n;i++)
		{
			if(a[i]>mx)
			{
				mx=a[i];
				pos=i;
			}
		}
		a[pos]-=n;
		for(int i=1;i<=n;i++)
			if(pos!=i)
				a[i]++;
		b--;
	}
	printf("%d\n",n);
	for(int i=1;i<=n;i++)
		printf("%lld ",a[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#define sentinel 2000000000
#define MAX 500000
int n,cnt;
int L[MAX/2+2],R[MAX/2+2];
void merge(int A[],int left,int mid,int right){
    int n1,n2,i,j,k;
    n1=mid-left;
    n2=right-mid;
    for(i=0;i<n1;i++) L[i]=A[left+i];
    for(i=0;i<n2;i++) R[i]=A[mid+i];

    i=j=0;
    L[n1]=R[n2]=sentinel;
    for(k=left;k<right;k++){
	cnt++;
	if(L[i]<=R[j]) A[k]=L[i++];
	else A[k]=R[j++];
    }
}

void mergeSort(int A[],int left,int right){
    int mid;
    if(left+1<right){
	mid=(left+right)/2;
	mergeSort(A,left,mid);
	mergeSort(A,mid,right);
	merge(A,left,mid,right);
    }
}

int main(void){
    int i;
    int A[MAX];

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

    mergeSort(A,0,n);
    
    for(i=0;i<n;i++){
	if(i) printf(" ");
	printf("%d",A[i]);
    }
    printf("\n");
    printf("%d\n",cnt);

    return 0;
}

Measured memory_bytes: 4508
#include "bits/stdc++.h"

using namespace std;
using VI = vector<int>;
using VPI = vector<pair<int, int>>;
using LL = long long;

#define FOR(a,n) for(int i=a;i<n;i++)
#define rFOR(a,n) for(int i=n-1;i>=a;i--)
#define IN(n,a) for(int i=0;i<n;i++) cin>>a[i]
#define pIN(n,t) for(int i=0;i<n;i++){int a,b; cin>>a>>b; t.emplace_back(a,b);}
#define SORT(a) sort(a.begin(), a.end())
#define ALL(a) a.begin(), a.end()

int main()
{
	int h, n;
	cin >> h >> n;

	VI a(n);
	IN(n, a);

	FOR(0, n)
	{
		h -= a[i];
	}
	if (h <= 0)cout << "Yes";
	else cout << "No";
}

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

tc = len( T )
ans = 0
for i in range( len(S) - tc + 1 ):
  cnt = 0
  for j in range( tc ):
    if S[ j + i ] == T[ j ]:
      cnt += 1
  ans = max( ans, cnt )
print( tc - ans )

Measured memory_bytes: 9100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define N 150
#define W (ll)2e5
ll n,k,memo[N][W],w[N],v[N];

ll dp(ll curr , ll rem) {
    if (curr > n) return 0;
    ll &sol = memo[curr][rem];
    if (sol != -1) return sol;
    sol = dp(curr + 1 , rem);
    if (rem >= w[curr])
        sol = max(
            dp(curr + 1 , rem - w[curr]) + v[curr] ,
            sol
        );
    return sol;
}

int main() {
    scanf("%lld%lld" , &n , &k);
    for (ll i = 1 ; i <= n ; i++)
        scanf("%lld%lld" , &w[i] , &v[i]);
    memset (memo , -1 , sizeof memo);
    printf("%lld\n" , dp(1 , k));
}


Measured memory_bytes: 238200
#include <stdio.h>

int divisor(int,int);


int main(){
    int a,b;

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

    printf("%d\n",divisor(a,b));

    return 0;
}

int divisor(int a,int b){
    int c= a % b ;
    if(c == 0){
        return b;
    }
    else {
        a = divisor(b,c);
        return 1*a;
    } 
}


Measured memory_bytes: 2140
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] cs = s.toCharArray();
        int[] a = new int[cs.length];
        int count = 0;
        int f = 0;
        for (int i = 0 ; i < cs.length ; i++) {
            if (f== 0) {
                if (cs[i] == 'A' ||cs[i] == 'T' || cs[i] == 'G' ||cs[i] == 'C') {
                    a[i] = 1;
                    count = 1;
                    f = 1;
                }
            } else {
                if (cs[i] == 'A' ||cs[i] == 'T' || cs[i] == 'G' ||cs[i] == 'C') {
                    count++;
                    a[i] = count;
                } else {
                    count = 0;
                    f = 0;
                }
            }

        }
        int max = 0;
        for (int i = 0 ; i < s.length() ; i++) {
            max = Math.max(max, a[i]);
        }
        System.out.println(max);
    }

}

Measured memory_bytes: 23764